Java System类console()方法及示例
系统类console()方法 (System class console() method)
console() method is available in java.lang package.
console()方法在java.lang包中可用。
console() method is used to return the console object which is uniquely associated with the current JVM(Java Virtual Machine) if exists.
如果存在,则使用console()方法返回与当前JVM(Java虚拟机)唯一关联的控制台对象。
console() method is static, it is accessible with the class name too.
console()方法是静态的,也可以使用类名进行访问。
console() method does not throw any exception.
console()方法不会引发任何异常。
Syntax:
句法:
public static Console console();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is Console, it returns the Console object if exists else it returns null when none of the System console exists.
此方法的返回类型为Console ,如果存在则返回Console对象,否则在不存在任何系统控制台时返回null。
Example:
例:
// Java program to demonstrate the example of
// console() method of System Class.
import java.io.*;
public class ConsoleMethod {public static void main(String[] args) {// Creating an object of Console
Console con = System.console();
if (con == null)
// Display when console is null
System.out.println("Null Console");
else {String str = con.readLine("%s", "Java Programming");
// Display when console is not null
System.out.println("The value of str is :" + str);
}
}
}
Output
输出量
E:\Programs>javac ConsoleMethod.java
E:\Programs>java ConsoleMethod
Null Console
翻译自: https://www.includehelp.com/java/system-class-console-method-with-example.aspx
Java System类console()方法及示例相关推荐
- java annotation class,Java Class类 isAnnotation()方法及示例
Class类isAnnotation()方法isAnnotation()方法在java.lang包中可用. isAnnotation()方法用于检查此Class对象是否表示注释类型. isAnnota ...
- getenv java_Java System类getenv()方法及示例
系统类getenv()方法getenv()方法在java.lang包中可用. getenv()方法用于返回键值对中当前环境变量的不可修改Map. 我们将看到什么是环境变量?环境变量是系统相关的外部命名 ...
- java字符类型的返回值,Java字符类isWhitespace()方法及示例
Character 类isWhitespace()法isWhitespace()方法在java.lang包中可用. isWhitespace()方法用于检查给定的char值是否为空格,但是它包含空格中 ...
- java system类_Java System类mapLibraryName()方法及示例
java system类 系统类mapLibraryName()方法 (System class mapLibraryName() method) mapLibraryName() method is ...
- java日历类add方法_Java日历computeTime()方法及示例
java日历类add方法 日历类computeTime()方法 (Calendar Class computeTime() method) computeTime() method is availa ...
- java日历类add方法_Java日历computeFields()方法及示例
java日历类add方法 日历类的computeFields()方法 (Calendar Class computeFields() method) computeFields() method is ...
- java日历类add方法_Java日历setFirstDayOfWeek()方法与示例
java日历类add方法 日历类setFirstDayOfWeek()方法 (Calendar Class setFirstDayOfWeek() method) setFirstDayOfWeek( ...
- java日历类add方法_Java日历setMinimalDaysInFirstWeek()方法与示例
java日历类add方法 日历类setMinimalDaysInFirstWeek()方法 (Calendar Class setMinimalDaysInFirstWeek() method) se ...
- java散列法的运用实例,Java HashMap compute() 使用方法及示例
Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...
最新文章
- 短网址有啥好处,用长网址不香吗?
- Spring boot的Webjars
- [css] 移动端1px像素的问题及解决方案是什么?
- MMdnn Visualizer网络可视化
- 添加游戏到游戏浏览器中的小工具
- asp.net web.config连接mysql数据库_ASP.NET中使用web.config配置数据库连接
- [USACO16OPEN]262144
- 怎么定义int_「C语言更新」C语言中如何来定义一个指针,并且对其进行初始化...
- 郑州双轨制直销系统开发奖金制度介绍
- u盘装服务器系统还原c盘失败,云骑士一键重装系统win10还原c盘失败怎么办
- 「Font」- 设置 Fallback 字体(如果字体 A 中不存在某个字符,则从字体 B 中加载该字符) @20210212
- Java中学生管理系统(对分数健康查询与修改)
- robotium和appium的一些区别(转)
- java 生成word 分页_Java 插入分页符和分节符到Word文档
- js打怪升级之路三 点出满天小星星
- 防止padding撑开盒子的方法
- 计算机的CPU的电路是多少KW,你的电脑多少瓦? 最全面的CPU功耗测试
- Qt中去掉空格和回车(两行代码)
- Windows下Bonobo.Git.Server服务器的搭建
- CANoe.DiVa 操作指南 - 逆向测试项设置