Source of BoxNonGeneric.java


  1: //BoxNonGeneric.java
  2: //A simple non-generic version of a Box class.
  3: //Since the private instance variable of this class is
  4: //of type Object, objects of any type can be stored in
  5: //class instances of this BoxNonGeneric class type.
  6: 
  7: public class BoxNonGeneric
  8: {
  9:     private Object object;
 10: 
 11:     public BoxNonGeneric(Object object)
 12:     {
 13:         this.object = object;
 14:     }
 15: 
 16:     public void setObject(Object object)
 17:     {
 18:         this.object = object;
 19:     }
 20: 
 21:     public Object getObject()
 22:     {
 23:         return object;
 24:     }
 25: 
 26:     //Show the type of object.
 27:     public void showType()
 28:     {
 29:         System.out.println(
 30:             "Type of object is " + object.getClass().getName()
 31:         );
 32:     }
 33: }