OutputStream

As you have experienced, programs output data to a screen, file, or elsewhere. In Java, this is possible with the OutputStream class. It is a class that supports output by providing overloaded methods for writing a sequence of bytes to a destination. The sequence is normally placed into a buffer, and the system then outputs the buffer at various times.

Methods such as print() and println() are overloaded to support standard data types like int, double, boolean, and others. These methods are responsible for converting the data type to a sequence of characters.

System.out

This is a predefined OutputStream object reference that is associated with a system's standard output, usually a computer screen.

The System class' out variable is a reference derived from OutputStream called a PrintStream. The PrinStream class extends the base functionality of the OutputStream class and provides print() and println() method for covering different types of data into a sequence of characters.

Note: The System class is predefined and you are not required to import it.


System.in

When you interact with a program, there are times you are required to input data to it. Whether is from a keyboard, or touchscreen. In Java, this can be achieved with System.in.

InputStream

InputStream is a class that provides overloaded read() methods that allow you to extract bytes from a particular source.

System.in

This is a predefined input stream object reference that is associated with a system's standard input, which is usually a keyboard.

This object reference automatically reads the standard input from a memory region known as a buffer which the operating system fills with input data.

Note: The System class is predefined and you are not required to import it.