interface USB{ //统一的接口 public void start(); public void stop(); } class Computert{ public void plugin(USB usb){ usb.start(); usb.stop(); } } class Flash implements USB{ //加入的设备遵循接口标准 @Override public void start() { System.out.println("开始U盘操作"); } @Override public void stop() { System.out.println("停止U盘操作"); } } public class InterfaceDemo { public static void main(String[] args){ Computert c = new Computert(); c.plugin(new Flash()); } }