title: Delete specified object in arraylist from another class in java
body: <p>I want to delete specified data in an arraylist from another class based on what the user input
  so when the user input Rice, the data with 'Rice' in it will be deleted
  this is the code so far</p>
  
  <p>the data is stored in ArrayList rm in a subclass named RegularMenu.</p>
  
  <pre><code>ArrayList&lt;RegularMenu&gt; rm = new ArrayList&lt;RegularMenu&gt;();
  
  Quiz1(){
      int input;
          do{
              System.out.println("1. Add Regular Menu");
              System.out.println("2. Add Special Menu");
              System.out.println("3. Show All Menu");
              System.out.println("4. Delete Regular Menu");
              System.out.println("5. Delete Special Menu");
              System.out.println("6. Exit" + "\n"); 
  
              System.out.print("Choice [1-6] ");
              Scanner s = new Scanner(System.in);
              input = s.nextInt();
  
              if (input == 1 ){
  
                  String code, name;
                  int price;
  
                  System.out.println("Add Regular Menu");
                  System.out.print("Input Menu Code [R...]: ");
                  s.nextLine();
                  code = s.nextLine();
  
                  System.out.print("Input Menu Name [5-20]: ");
                  name = s.nextLine();
  
                  System.out.print("Input Menu Price [10000-130000]: ");
                  price = s.nextInt();
  
                  rm.add(new RegularMenu(code, name, price));
              }
  
              else if (input == 2){
  
              }
  
              else if (input == 3){
  
              }
  
              else if (input == 4){
  
  
                  System.out.println("Input menu code you want to delete");
                  String a = s.nextLine();
  
                  for(int i=0;i&lt;rm.size();i++){
                      if(a == rm.get(i).getCode()){
                          String code = rm.get(i).getCode();
                          a = code;
                          rm.remove(a);
                      }
  
                  }
  
              }
  
              else if (input == 5){
  
              }
          }while(input != 6);
  }
  </code></pre>
  
  <p>i can add the data, but when try to remove it, the error occurred.
  Let me know if I'm not clear enough.</p>