用Telphone iphone = new Iphone();和Iphone iphone = new Iphone();具體區別?
public class Text {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Telphone iphone = new Iphone();
iphone.call();
iphone.messge();
Callphone callphone = new Callphone();
callphone.call();
callphone.messge();
}
}
2016-02-21
Telphone iphone=new Iphone();屬于多態性中的向下轉型
子類 子類對象=父類實例
補充:向上轉型 ?父類 父類對象=子類實例
Iphone iphone=new Iphone();
這個就是正常情況通過類名創建對象并實例化