This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See John Dell'Oso
posted 11 years ago
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:
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..
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad: