The Java Console class is be used to get input from console. It gives way(method) s to read texts
And passwords.
If you read password using Console class, it will not be out put to the user.
The java.io.Console class is reattached with system console innerly. The Console class is
introduced .
Let’s see a simple example to read text from console.
1. String text=System.console().readLine();
2. System.out.println(“name is: “+text);
Java Console Example
import java.io.Console;
class ReadStringTest{
public static void main(String args[]){
Console c=System.console();
System.out.println(“Enter your name: “);
String n=c.readLine();
System.out.println(“Welcome “+n); } }
output
Enter your name: Rawan
Welcome Rawan