want to add searchBook udpateBook deleteBook in linked list in java -


package pro; import java.util.scanner;  public class bookapp {     static book head, pointer;     static scanner input = new scanner(system.in);      public static void main(string[] args) {         system.out.println("welcome szabist book store");          int choice = 0;         {             system.out.println();             system.out.println("1. insert book");             system.out.println("2. delete book");             system.out.println("3. udpate book");             system.out.println("4. search book");             system.out.println("5. view book(s)");             system.out.println("6. exit");              system.out.print("enter choice: ");             try {                 choice = integer.parseint(input.nextline());             } catch (exception e) {                 e.printstacktrace();             }             switch (choice) {             case 1:                 addbook();                 break;             case 2:                 deletebook();                 break;             case 3:                 udpatebook();                 break;             case 4:                 searchbook();                 break;             case 5:                 viewbook();                 break;             case 6:                 input.close();                 system.exit(0);                 break;             default:                 system.out.println("wrong choice try again!");             }          } while (true);       }      private static void viewbook() {         if (head == null) {             system.out.println("list empty !");         } else {             pointer = head;             (book = pointer; != null; = pointer.next) {                 system.out.println(pointer.getbook());                 pointer = pointer.next;             }         }      }      private static void searchbook() {         // todo auto-generated method stub      }      private static void udpatebook() {         // todo auto-generated method stub      }      private static void deletebook() {         // todo auto-generated method stub      }      public static void addbook() {         if (head == null) {             string details[] = enterdetails();             pointer = new book(details[0], details[1], details[2]);             head = pointer;             pointer.next = null;         } else {             string details[] = enterdetails();             pointer.next = new book(details[0], details[1], details[2]);             pointer = pointer.next;             pointer.next = null;         }      }      public static string[] enterdetails() {         string[] details = new string[3];         try {             string title;             string isbn;             system.out.print("please enter book title: ");             title = input.nextline();              system.out.print("please enter book isbn: ");             isbn = input.nextline();              string authors;             system.out.print("enter book author(s): ");             authors = input.nextline();             details[0] = title;             details[1] = isbn;             details[2] = authors;          } catch (exception e) {             e.printstacktrace();         } {          }         return details;     }  }  //class package pro;  public class book {     string[] authors;     static string publisher;     final string isbn;     final string title;     book next;      book(string title, string isbn, string... authors){         this.isbn = isbn;         this.title = title;         this.authors = new string[authors.length];         int i=0;         (string s: authors){             this.authors[i]=s;             i++;         }     }      public string getbook(){         return "book title: " + this.title + "\n" + "book isbn: " + this.isbn +                  "\n" + "book author(s):" + getauthors() +"\n"                 ;     }      public string getauthors(){         stringbuilder s = new stringbuilder();         (string s1: this.authors){             s.append(s1 + ",");         }         return s.tostring();     }  } 

want add search book update book delete book in linked list in java when press 2 update book when press 3 search book when press 4 delete book in linked list in java. cant find way out

call book id search search method.

private static void book searchbook(int book_id) {  if(head == null)    return null;  book iterator = head;  while(iterator != null){   if(iterator.getid() == book_id){    return iterator;   }   iterator = iterator.next;  }  return null; } 

Comments