If a String
object is immutable then why is it printing "Help"?
The String object s1
shouldn't be modified according to its immutability feature. I am confused for years, please help me understand this:
Code
public static void main(String[] args) {
String s1 = "Hello";
s1 = "Help";
System.out.println(s1);
}
Output
Help