没有泛型之前 ObjectFoo fool = new objectFoo()i ObjectFoo foo2 new objectFoo( fool. setFoo(new Boolean(true))i //记得转换实现类型 Boolean b =(Boolean) fool. getFoo(i foo2 setFoo (new Integer(10))i //记得转换实现类型 Integer i =(Integer) foo2 getFoo o)i 转换型态时用错了型态 ObjectFoo fool new objectFoo ()i fool. setFoo(new Boolean(true))i String s=(String) fool. getFoo ()i ClassCastException• 转换型态时用错了型态 没有泛型之前 ObjectFoo foo1 = new ObjectFoo(); ObjectFoo foo2 = new ObjectFoo(); foo1.setFoo(new Boolean(true)); //记得转换实现类型 Boolean b =(Boolean) foo1.getFoo(); foo2.setFoo(new Integer(10)); //记得转换实现类型 Integer i =(Integer) foo2.getFoo(); ObjectFoo foo1 = new ObjectFoo(); foo1.setFoo(new Boolean(true)); String s = (String) foo1.getFoo(); ClassCastException