private void showMenu() { String input = ""; do { Iterator<Artist> iter = currentArtists.iterator(); // display all current results with an associated index number for (int j = 1; j <= currentArtists.size(); j++) { Artist a = iter.next(); System.out.println("[" + j + "] " + a.getName()); } System.out.println("-"); System.out.println("[L] List traveled artists"); System.out.println("[q] Quit program"); // prompt System.out.println(separator); System.out.println("Which artist do you want to check out?"); System.out.print("Enter his/her index number or enter 'q' to exit: "); System.out.flush(); ArtistNode anode = null; try { input = in.readLine(); int neuerIndex = Integer.parseInt(input); // if the index exceeds the array's bounds, prompt again if (neuerIndex > currentArtists.size() || neuerIndex < 1) System.out.println("There is no such index! Please re-try your request, would you?"); else { // fetch the selected artist - it will become the new center Artist a = (Artist) ((ArrayList<Artist>) currentArtists).get(neuerIndex - 1); anode = ui.retrieveArtistInformation(a.getName()); displayArtistInformation(anode); currentArtists = ui.findArtistsByName(a.getName()); System.out.println(separator); } } catch (UnknownHostException e) { System.out.println( "You don't seem to have established a working internet " + "connection going on right now. Please fix that and try again."); System.exit(1); } catch (IOException e) { e.printStackTrace(); } catch (NumberFormatException e) { if (input.equals("L")) { listTraveledArtists(); System.out.println(separator); } else if (input.equals("q")) break; else System.out.println( "I believe you screwed up the index input (your input: " + input + ")" + "\n Would you mind doing it again, please?"); } catch (NoSuchEntryException e) { System.out.println("There was an entry retrieval error! The code is " + e.getMessage()); } } while (!input.equals("q")); }