各位,我有个小问题,不知道为什么;新人
程序代码:
public class USBConsole { public static void main(String[] args) { IUSBable m = new mouse(); USBConsoleTable.insertInUSB(m); IUSBable k = new keyboard(); USBConsoleTable.insertInUSB(k); USBConsoleTable.insertInUSB(new keyboard()); } } interface IUSBable { void dosomth(); } class mouse implements IUSBable { public void dosomth() { System.out.println("tic...tic...mouse working."); } } class keyboard implements IUSBable { public void dosomth() { System.out.println("da....da...da..keyboard working."); } } class USBConsoleTable { private static IUSBable[] USBss = new IUSBable[6]; private static int indx = 0; static void insertInUSB(IUSBable USBs) { if (indx > USBss.length) { System.out.println("USB插口不足"); return; } else if (USBss[indx] != null) { USBss[indx]=USBs; USBs.dosomth(); indx++; } } }
这个是我在自学的时候写的一个练习的代码,但是为什么没有输出println中的内容呢?