System class
The System class provides facilities such as the standard input, output and error streams. It also provides means to access properties associated with the Java runtime system and various environment properties such as version, path, vendor and so on. Fields of this class are in, out and err which represent the standard input, output and error respectively.
Java Console Class
The Java Console class is be used to get
input from console. Console class comes under Java.io.Console class
Let's see the code to get the
instance of Console class.
Console c=System.console();
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
to "+n);
}
}
Output
Enter your name: Information Tech
Welcome to Information Tech
0 comments:
Post a Comment