怎么使用Dog2這個(gè)引用?
package imooc;
public class Initial {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
dog Dog=new dog();
animal Animal = Dog;
if (Animal instanceof dog){
dog Dog2=(dog)Animal;
}else{
System.out.print("無(wú)法轉(zhuǎn)換");
}
}
}
2016-08-15
代碼沒(méi)錯(cuò)和dog一樣使用啊,另外最好類(lèi)名大寫(xiě),引用小寫(xiě)