} else if (selectionKey == 2) {
System.out.println("Please enter the item name");
if (s.nextLine() != "") {
item = s.nextLine();
}
try {
ZybezChecker zb = new ZybezChecker(item);
zb.getAveragePrice();
System.out.println(zb.toString());
} catch(Exception e) {
System.out.println("Something went wrong. Perhaps an invalid item name?");
}
這是我的代碼atm。如何返回if語句並在捕獲後繼續循環?嘗試捕捉後返回到前一個循環的點嗎?
如果你需要做這樣的事情,你有一個設計缺陷。嘗試將代碼移到某個函數或其他東西。 – ShellFish