• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

println() method

 
rajeshchowdary rajesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to access methods we can create ojects to the classes to which the method belongs .and by using objectname.methodname() we can access methods.But we are using System.out.println() why ? is there any other alternate to access println method ehich is in printstraem class?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.System is a class.

"out" is a static field of the System class. Being static, it exists independent of an instance of the System class. The type of "out" is java.io.PrintStream.

So, "System.out" gives you an instance of PrintStream, on which you are calling the method println().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic