Java Console ClassThe Java Console class is be used to get input from console. It provides methods to read texts and passwords. If you read password using Console class, it will not be displayed to the user. The java.io.Console class is attached with system console internally. The Console class is introduced since 1.5. Let's see a simple example to read text from console. Java Console class declarationLet's see the declaration for Java.io.Console class: Java Console class methods
How to get the object of ConsoleSystem class provides a static method console() that returns the singleton instance of Console class. Let's see the code to get the instance of Console class. Java Console ExampleOutput Enter your name: Nakul Jain Welcome Nakul Jain Java Console Example to read passwordOutput Enter password: Password is: 123 Next TopicJava FilePermission Class |