String Comparisons in Java

If I pass the text “Ninja” as strWarriorType to a method, the following evaluate as true:


But this evaluates as false:

strWarriorType.toUpperCase() == "NINJA"


Update: Illumination from a Friend

I did similar tests in PHP, C#, and Python and discovered that they all handled my == operator exactly as I expected.  New stuff has been learned!

Leave a Reply

Your email address will not be published. Required fields are marked *