I have a method, which search in an ArrayList what contains objects with two private fields. Here is the method:
public int searchContactName(String name){
    int foundIndex =-1;
    for(int i = 0; i < contacts.size(); i++){
        if(contacts.get(i).getName() == name){
            foundIndex = i;
        }
    }
    return foundIndex;
}
It's work well if I use it like this:
searchContactName("xyName");
But if I try to use it with a scenner.next() like thins, for the same name
String name = scanner.next();
searchContactName(name);
It's give me -1. I don't understand, I need to format some way the input? It is the same type or it is different some way if I use the scanner?
 
     
     
     
     
     
     
    