Wednesday, 22 August 2012

System.out.print() - Java

In core java System.out.print() is mainly used to print something on screen. Here is little deep analysis of this statement.
System is very useful class in java. It is present from JDK 1.0.
Ex. System.out.print("Hello..."); //It will simply print [Hello...] on screen.

1. System class shows three fields in, out, err. All three fields are streams.

2. System class is public and final by nature.

3. Out of three err and out are of type PrintStream and in is of type InputStream.

4. All three streams are public, static and final by nature. public means can be accessed anywhere, static means we can use these streams without object of System class and final means we can't override these streams.

5.  PrintStream is a class in java.io package which is public by nature.

6. PrintStream class shows [public void print method()].

7. InputStream is a class present in java.io package which is public and abstract by nature.

8. InputStream shows methods like read().

9. out and err are streams which displays output to standard output device means monitor. But we can redirect output to some other device.

10. in is a stream which supplies input data from standard input device i.e. keyboard. But we can use some other device as well.

11.  So finally we are using print and println methods of PrintStream class through System.

No comments:

Post a Comment