PrintStream

PrintStream


The PrintStream is designed to print data at DOS prompt with its print() and println() methods. This stream comes with the ability of automatic flushing of data. In contrary to the methods of all I/O streams, the methods of PrintStream class do not throw IOException. PrintStream methods are deprecated in favor of PrintWriter, but not System.out. There exists a similar class on character streams side, PrintWriter with println() method.

The println() and print() methods are overloaded many times in the PrintStream class to accept different data types and objects as parameters. println() method is overloaded 10 times and print() method is overloaded 9 times.

Writing at DOS prompt

In the code, both println() and print() methods are used to print at the DOS prompt.

PrintStream

Observe, the false and 10.5 come in the same line as false is printed with print() method and not with println() method.

Leave a Reply

Your email address will not be published. Required fields are marked *