Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the meaning of System.out.println in Java?

Is this static println function in out class from System namespace?

 namespace System {   class out {     static println ...   } 

How can I interpret this name? And where in JRE this function is defined? In java.lang.System/java.lang.Object?

like image 580
prosseek Avatar asked Aug 04 '10 14:08

prosseek


People also ask

What is meaning of system out Println in Java?

In Java, System. out. println() is a statement which prints the argument passed to it. The println() method display results on the monitor. Usually, a method is invoked by objectname.

What is system and out in system out print?

System is a final class which is present in java. lang package. out is the reference of PrintStream class and a static member of System class.


2 Answers

No. Actually out is a static member in the System class (not as in .NET), being an instance of PrintStream. And println is a normal (overloaded) method of the PrintStream class.

See http://download.oracle.com/javase/6/docs/api/java/lang/System.html#out.

Actually, if out/err/in were classes, they would be named with capital character (Out/Err/In) due to the naming convention (ignoring grammar).

like image 191
kennytm Avatar answered Sep 21 '22 19:09

kennytm


System is a class, that has a public static field out. So it's more like

class System  {     public static PrintStream out; }  class PrintStream {     public void println ... } 

This is a slight oversimplification, as the PrintStream class is actually in the java.io package, but it's good enough to show the relationship of stuff.

like image 40
cHao Avatar answered Sep 19 '22 19:09

cHao