创建主类主方法:
package cm.interfaces.application2;
public class MainClass {
public MainClass() {}
public static void main(String[] args) {
// TODO Auto-generated method stub
//创建变量、对象、字段的日常小黄线:The value of the local variable c is not used
Computer c = new Computer();
c.usb();
c.phone();
c.print();
c.mp3();
c.computer();
}
}
创建USB接口,USB设备及其具有的功能:
package cm.interfaces.application2;
//因为他能连接很多设备,具备每一项设备的功能链接,并在计算机上最终得到实现或体现
public interface USB extends Phone, Print, MP3{
void usb();
}
//定义1:定义手机类接口,声明手机接口功能
interface Phone{
void phone();
}
//定义2:创建打印机接口,定义其接口功能
interface Print{
void print();
}
//定义3:声明MP3接口,创建其功能
interface MP3{
void mp3();
众多USB设备,通过连接USB接口,功能在电脑上得到最终实现或体现:
package cm.interfaces.application2;
//以USB接口为实