I am trying to loop through an ArrayList contining Football club objects. I am trying to retrieve the name and compare to user input to check if it's a valid team. When checking, it checks first input (team1) and manages to find out if its in the ArrayList or not but for the second one it does not. Even if (team2) exists in the ArrayList as a valid team, it still says it does not exist
String team1 = userInput.nextLine();
String team2 = userInput.nextLine();
for(int i =0; i < addStats.size(); i++)
{
if(addStats.get(i).getClubName().equals(team1)) {
for(FootballClub clubs: addStats)
{
if(clubs.getClubName().equals(team2))
{
break;
}
else{
System.out.println(team2 + " is not a valid team");
return;
}
}
break;
} else {
System.out.println(addStats.get(i).getClubName());
System.out.println(team1 + " is not a valid team");
return;
}
}