private void Deletepublisher() throws SQLException { boolean exit_Add = false; int id; Set<Publisher> set = as.listpublisher3(); System.out.println("\nPublisher ID | Publisher Name | Publisher Address | Publisher Phone "); System.out.println("----------------------------------------------------------------------"); Set<Integer> sk = new HashSet<Integer>(); for (Publisher s : set) { sk.add(s.getPublisherId()); System.out.println( s.getPublisherId() + "\t " + s.getPublisherName() + "\t " + s.getPublisherAddress() + "\t " + s.getPublisherPhone()); } do { System.out.println(); System.out.println("Enter the Publisher Id you want to delete:"); try { id = Integer.parseInt(sc.nextLine().trim()); if (sk.contains(id)) { Publisher p = new Publisher(); p.setPublisherId(id); as.deletePublisher(p); System.out.println("Deletion successful!"); } else { System.out.println("This Id does not exist exists."); } } catch (Exception e) { System.out.println("INFO:Should be an integer!"); } if (!exit_Add) { System.out.println(); System.out.println(); System.out.println("Press ' q ' to return or any other key to continue"); String option = (sc.nextLine()); if (option.length() > 0) { switch (option.charAt(0)) { case 'q': exit_Add = true; break; default: exit_Add = false; break; } } } } while (!exit_Add); }