Thread: Object
View Single Post
  #2 (permalink)  
Old 01-10-2008, 02:31 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
Code:
public class Test { public static void main(String[] args) { BoxRx box = new BoxRx(); Object x = "x"; box.add(x); Object whatIsIt = box.get(); System.out.printf("whatIsIt = %s%nwhat class is it = %s%n", whatIsIt, x.getClass().getName()); box.add(75); whatIsIt = box.get(); System.out.println("whatIsIt = " + whatIsIt); } } class BoxRx { private Object object; public void add(Object object) { this.object = object; } public Object get() { return object; } }
Reply With Quote