Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

system.out.println()

 
rayal singam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
what exactly these terms represents.what is the relation b/w system and out here.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to "Java in General (beginner)".
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean System.out.println() ... (notice the uppercase 'S')

Well, System is a class, out is a static field defined in the System class that is a reference to a PrintStream object (in this case the standard output stream) and println() is a method of the PrintStream class.

All this information is available from the JDK javadocs:

JDK Documentation

Regards,
JD
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to understand this.. you are supposed to understand some more logic.




with the above example u can use the obj of the Aclass to acces any method of the Bclass by calling Aclass.obj.BclassMethod() just like system.out.println()

and also there is nothing called static object. it is always called only static reference. no static object. so any static content can be called using classname.(dot) staic member name. like that here obj is a static member. so u can use Aclass.obj.disp() jus like System.out.println()

i hope u got it.. the reason it is marked static is that if it is static we can use it inside main.. since main is static or even if we require we can use it outside also.. because System.out.println() is used anywhere. so it has no problem saying static content cant be referenced from non-static etc etc error... so now it is safe from the errors..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic