This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
You're using == to compare Strings, which you should never do. Sometimes it will behave as you expect because of various internal optimisations (which is what you're seeing on the first couple of lines), but not always. Use the equals() method instead.