/* * T04n03.java: Just a small demo of why overriding the Object class' * toString() method is a darn good idea. */ import java.io.*; class Shoelace extends Object // "extends Object" is optional; it's the default { StringBuilder sb; // Pop quiz: An example of class ...? public Shoelace (String mesg) { sb = new StringBuilder(mesg); } ///* // remove the double slashes to comment out toString() public String toString() { return sb.toString(); } //*/ // remove the double slashes to comment out toString() } public class T04n03 { public static void main (String [] args) { Shoelace message = new Shoelace("I'm better than a string!"); System.out.println(message.toString()); } }