這是爲什麼就不行,任何一個可以給這一個....我們可以指定一個異常類對象Object類對象的引用
public class Manager
{
public static void main(String args[])
{
try{
Object obj=new A(); //it will generate ClassNotFoundException object
System.out.println("currently the reference obj is pointer to the object:"+obj);
}catch(Object o)
{
System.out.println(o);
}
}
System.out.println("End of Main");
}
將你的對象包裝在一個Exception中,然後拋出Exception。在Catch子句中,您可以通過Exception找到對象。 – bzlm 2010-08-05 12:59:08