2008年1月13日 星期日

instanceof

instanceof是用來判斷一個reference是不是屬於某一個類別或介面的函式。例:

System.out.print(new String() instanceof Object);

結果會回傳印出true,因為String是Object的子類別,所以函式會回傳true。

0 意見: