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
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.