Use String.equals(String) to compare Strings. For objects (which a String is), .equals() method compares "equality", while == compares if they are physically the same object in memory.