Site icon TestingDocs.com

Keyboard Interaction in Java

Overview

Let’s learn the keyboard interaction in Java programming language. The keyboard is a standard input device to communicate with the Java program. In Java, keyboard data can be read in many ways.

Keyboard Interaction

Some ways to interact using the keyboard are as follows:

Java facilities three stream objects to communicate with standard input and output devices. The streams are defined in the System class.

System.in

The System.in is the standard input stream. It is the representation of the InputStream object. The stream automatically maintains the connection between the standard input device(keyboard) and the Java program. This stream is already open and ready to supply input data.

System.out

The System.out is the standard output stream. It is the representation of the PrintStream object. The stream automatically maintains the connection between the Java program and the standard output device(computer monitor ). This stream is already open and ready to accept output data.

System.err

The System.err is the standard error output stream. It is the representation of the PrintStream object. The stream automatically maintains the connection between the Java program and the standard output device(computer monitor ) to display error messages.

Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/java/

Exit mobile version