Java.io.Console class is a new class in Java 6 that may be used for reading text from character based console device. The data can be read from the console device provided it is associated with the Java Virtual Machine (JVM).
To determine whether console device is present in the current JVM, we invoke Console() method of System class and if this method returns a Console reference, that means the console device is present in current JVM as shown in following code:
If console device is present in current JVM, we get a console reference which can be used to call the Console class's methods.
Here is the Java Example for Console I/O:
public class ConsoleIO
public static void main(String args)
val=console.readLine("Enter first value ");
val=console.readLine("enter second value ");
val=console.readLine("Enter third value ");
System.out.println("Average of three variables is "+a);