Hi, System ----- > Class present in the java.lang package which cannot be instantiated. out -------- > Static final variable declared in the System class.Hence, you say System.out(without creating a instance of the Sustem class). It is of the type java.io.PrintStream. println ---- > Method present in the PrintStream class to send the output to the specified stream.Since, out is an instance of PrintStream, we say out.println to invoke this method.
Also the print() and println() methods (println() adds a carriage return, print() does not) when passed an Object, automatically uses that object's toString() method to render the output. In the case of a String object, this is the string value of the object. In the event of another kind of object it is either the result of an overridden implentation of toString() or Object.toString() (which all objects inherit and, if not overriden, which prints the object's class name + @ + hexadecimal representation of the hash code of the object). From the Object javadocs: The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode()) --BW [ November 25, 2003: Message edited by: Brian R. Wainwright ]
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop