2
I’m having trouble with this array exercise:
a) Create the Blocodenotes class that has an attribute
ArrayList<String>called notes. Create methods to insert, remove and fetch notes. Create a method that prints all notes.b) Create the Appblock class, with a main method, and a menu that
1) Enter a note,
2) Remove a note,
3) Change a note,
4) List all notes and
5) Exit from the system.
What I’ve done so far:
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class BlocoDeNotas{
  private ArrayList<String> notas = new ArrayList<String>();
  public void inserirNota (String nota){
   notas.add(nota);
  }
  public int buscarNota (String nota){
   for(int i=0; i < notas.size(); i++){
      if(notas.get(i).equals(nota))
        return i;            
   }
   return -1;  
  }
  public boolean removerNota(String nota){
   int posicao = buscarNota(nota);
   if (posicao >= 0){
      notas.remove(posicao);
      return true;
   } 
   return false;
  }
  public void listarNotas(){
   for (String minhaNota:notas){
      System.out.println(minhaNota);
   }
  } 
}
It is missing to make the method to change a note, requested in the statement. How do I do this?