this is because toUpperCase() is clever enough to realize that there's nothing to do an lets the strings untouched. Make "STRiNG" out of "STRING" for example and the output will be "Not Equal".
As your both "STRING" are in capital letters, so the toUpperCase method will not create a new object, so it's like your comparing "STRING" to "STRING". As sson as the toUppercase makes a changes (for instance try "StRING".toUpperCase ), you'll see that your class will prints not equals. Hope this will help
SCJP 5 (76%)
SCWCD 5 (86%)
SCBCD 5(70%)
--------------------
"The greatest glory in living lies not in never falling, but in raising every time we fall.".. Nelson Mandela
And please note that same object is returned by String modifier methods, if their is nothing to modify. The same happens with trim() method as in toUpperCase() as shown by you.
SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
You actually can look into String, toUpperCase() and replace() methods source code. If you have IDE like NetBeans installed you can even step into those methods with debugger and see whats going on inside.
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, the permaculture playing cards