public void enterCustomers() {
System.out.println("Enter customer names or press q to quit entering names: ");
while (true) {
String name;
double balance;
System.out.print("Enter a customer name: ");
name = input.next();
System.out.print("Enter the opening balance : ");
balance = input.nextDouble();
accounts.add(new Account(name, balance));
if ( name == "q") {
break;
}
}
}
I dont know why my if statement does not work to break the loop. when press q when i run it does not do anything.
Aucun commentaire:
Enregistrer un commentaire