标签:
interface USB{
publicvoid read();
publicvoid write();
}
interface Wifi{
publicvoid open();
publicvoid close();
}
classPhone implements USB,Wifi{
publicvoid read(){
System.out.println("USB read");
}
publicvoid write(){
System.out.println("USB write");
}
publicvoid open(){
System.out.println("Wifi open");
}
publicvoid close(){
System.out.println("Wifi close");
}
}
classTest{
publicstaticvoid main(String args[]){
Phone phone =newPhone();
//向上转型
USB usb = phone;
usb.read();
usb.write();
Wifi wifi = phone;
wifi.open();
wifi.close();
}
}
interface A{
publicvoid funA();
}
interface B{
publicvoid funB();
}
interface C extends A,B{
publicvoid funC();
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815456.html