public class Box // simple class to demonstrate boxing a type, passed in as T { private T item; // our instance datum, an object of type T (to be filled in as a parameter when constructed) public Box(T item) // constructor { this.item=item; } public T get() // accessor { return item; } public void set(T item) // mutator { this.item=item; } public String toString() // if T has a toString, this returns the item as a String, otherwise it will { // return the memory location (or "not set" if item is null) if(item!=null) return ""+item; else return "not set"; } // implements a static method assuming the T extends Number, we cover this later in the chapter public static boolean greater(Box item1, Box item2) { if(item1.get().doubleValue()>item2.get().doubleValue()) return true; else return false; } }