日期:2014-05-20 浏览次数:20761 次
MyClassLoader ml = new MyClassLoader(); MyClassLoader ml2 = new MyClassLoader(); Class c1 = ml.loadClass("TestClass"); Class c2 = ml2.loadClass("TestClass"); TestClass tc1 = (TestClass) c1.newInstance(); TestClass tc2 = (TestClass) c2.newInstance(); System.out.println("TestClass[" + c1.hashCode() + "] loaded by MyClassLoader[" + ml.hashCode() + "]"); System.out.println("TestClass[" + c2.hashCode() + "] loaded by MyClassLoader[" + ml2.hashCode() + "]"); System.out.println("Object 1 [" + tc1.hashCode() + "] is instance of TestClass[" + c1.hashCode() + "]"); System.out.println("Object 2 [" + tc2.hashCode() + "] is instance of TestClass[" + c2.hashCode() + "]"); System.out.println(tc1.equals(tc2));