This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
i.e. use the equals() method of string, rather than ==, since the latter only compares the memory location of the two objects (which will always be false in this case) rather than compare their content, which is what you want.
Or to try and put it in a C++ perspective what you typed is:
what you want is:
In the first instance you compare pointers which are obviously different. In the second you compare the content of the pointers which is identical (a letter e). In Java that's done through equals() more or less as you compare the content of objects (so not just the content of data referred to by a pointer location as in the second example).