I understand that strings are immutable. Once a
string is given a value, it's value can never change. However, when the following small program is run, it prints true. Why? Doesn't s2.toUpperCase() change s2's original value? Here's the program:
class A
{
public static void main(String[] args)
{
String s1="HELLO WORLD";
String s2="hello world";
if(s1.equals(s2.toUpperCase()) == true)
System.out.println("true");
}
}