// You may override the $toString$ method to provide more useful information, public class object2 { public static void main(String[] args) { // Printing a reference to an object means Java calls $toString$. // In this case, Class $A$ overrides $toString$. So, Java // calls $A$'s implementation of $toString$. System.out.println( new A() ); } } class A { int j = 1; int k = 2; public String toString() { return "j = " + j + ", k = " + k; } } /* Output: j = 1, k = 2 */