public static void searchName() {??System.out.println("輸入圖書(shū)名稱(chēng)");??try {???scan = new Scanner(System.in);???String input = scan.nextLine();???for (int i = 0; i < 9; i++) {????if (books[i].equals(input)) {?????System.out.println("book:" + books[i]);????}//如果在這里加else{?System.out.println("圖書(shū)不存在!");}的話會(huì)出現(xiàn)9句“此圖書(shū)不存在”,應(yīng)該怎么解決這個(gè)問(wèn)題???}??} catch (Exception e) {???System.out.println("圖書(shū)不存在!");??}?}
遍歷數(shù)組完畢之后,發(fā)現(xiàn)沒(méi)有此名稱(chēng)的圖書(shū),輸出“此圖書(shū)不存在”,應(yīng)該怎么實(shí)現(xiàn)?
小雨_veronica
2016-11-23 20:31:21