Try replacing the == with equals(searchKey), that should fix the problem. If you don't care whether letters are upper or lower case, you can instead use equalsIgnoreCase(searchKey).