Just wondering System.out.println()

Go To StackoverFlow.com


Just asking if I have the right understanding


System is the package out is the class println() is the method

If this is wrong, then please tell me what the correct answer is.

2012-04-04 04:18
by user1293258



  • System is the class, which resides in java.lang package (that's why you don't need to import it).
  • out is a static variable of System class. It is public, so that you can access it from outside and it is static so that you it's associated to the class declaration and not to any instance of it.
  • println() is a method, indeed. And it is a method of out variable, which is a PrintStream instance.
2012-04-04 04:21
by Jack
so PrintStream is the Class and out is the static instance of that class? - user1293258 2012-04-04 04:29
no, System is the class, out is a static instance of a PrintWriter class. This instance is contained in System but since it's static it belongs to the System namespace itself and not to any instance of System - Jack 2012-04-04 04:31
ok I get that. Another question in java.lang.package.. is package here is the library?? because in java.lang.math.. math is the library - user1293258 2012-04-04 04:36
Java doesn't make a distinction between "package" and "library." If you mean java.lang.Math, Math is a class - Louis Wasserman 2012-04-04 05:01


out is a static object of printstream class
System -class,

PrintStream -class,

out - static object of PrintStream class ,

println - public method in PrintStream Class

2012-04-04 04:22
by keety


System = class
out = static object of the PrintStream class
println() = method

read this http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html

2012-04-04 04:23
by shan


System is not a package. It is a class which is contained inside java.lang package

Take a look here http://docs.oracle.com/javase/7/docs/api/java/lang/System.html

out is a PrintStream object (static in case of System class) in which println() is one of the methods

2012-04-04 04:24
by Sunil Kumar B M
System is NOT an object. It is a class that is designed to never be instantiated - Stephen C 2012-04-04 06:09


System is a class from package java.lang. out is a public, static member of System class, and println is a method, yes.

2012-04-04 04:26
by Mukesh Soni


No, your understanding is wrong.

"Then What is right" -

System - a class,

out - a static public member of type PrintStream ,

and oh yes println() is a method.

You were 33% right ;) read java documentation for this here

2012-04-04 04:24
by ring bearer