samedi 12 juin 2021

coding on Bluej with open university packages installed (not for course work) [duplicate]

this is a block of code that im writing (OUDialog is a package from the open university version of bluej that acts like a msgBox):

   public void addItems(String accName){
      for (int i=0;i<Accounts.size();i++){
         if (Accounts.get(i).getName()==accName){
            adding = true;
            while (adding==true){
               String choose = OUDialog.request("enter 'y' to continue.");
               if (choose=="y"){
                  Accounts.get(i).addEntrie();
               }else{
                  adding = false;
               }
            }
         }
      }      
   }

as far as i can tell everything should be working but when i run this method this if statement refuses to cooperate:

if (choose=="y"){
   Accounts.get(i).addEntrie();
}else{
   adding = false;
}

I have know idea why it cant detect when I enter "y" and cant find answers anywhere else.

P.S. im asking here because i already finished my java programming course w/ the OU and cant ask my tutor.

Aucun commentaire:

Enregistrer un commentaire