Most objects in Java have a
toString() method, which returns a
String-ified version of the object. This is one of the methods that you will most frequently
Some things in Java are self evaluating, which means they'll return themselves. You may've realized this initially, when we were evaluating primative data types -
System.out.println(true); // Prints 'true' System.out.println(42); // Prints 42 System.out.println(87.18); // Prints 87.18
String greeting = "Hello"; System.out.println(greeting); // Prints "Hello" String goodbye = new String("Goodbye"); System.out.println(goodbye); // Prints "Goodbye"
Arrays and other "container" objects are self-evaluating if they contain self-evaluating objects. For example, an array of
booleans is self evaluating, while an array of
Cars is not.