dimanche 4 mars 2018

Not able to get into if statement(issue with string to string)

I have done this assignment in c++ but maybe since im doing it in java im making a super simple mistake that i cannot see. No matter what unless i make the if statement just true it has not became true. any advice?

 if (input == 3) {
//if no teams then no teams

if (names == null) {
System.out.println("no teams");
}

//ask who won
else {
System.out.println("who won");
String whoWon = keyboard.nextLine(); //or next

//loop through array name and wins
for (int i = 0; i < names.length;i++) {
//here is where
if (names[i]==whoWon) { 

win[i] = win[i] + 1;
System.out.println(whoWon + " has plus one wins");
}
else {
System.out.println("no team by that name");
     }
}

Aucun commentaire:

Enregistrer un commentaire