Hi I have a strange problem with my code and I cant figure out whats wrong.
I have:
ArrayList called players
Class: Player
Class: Name
Player class contains Name class which contains 3 Strings FirstName MiddleName LastName
The problem is when im trying to do
For( int i = 0; i < players.size(); i++)
{
if( players.get(i).getName().getFirst() == "First1")
{
// Some Code
}
System.out.printf(players.get(i).getName().getFirst());
}
If statement is never true, weird thing is when im using system.out to check as below
System.out.printf(players.get(i).getName().getFirst());
it returns:
First1 First2 First3
getName() method returns object name and getFirst() returns String FirstName
Any ideas where the problem is?