Are String class and String objects immutable in java?
String class is immutable
String objects are immutable
both options 1 and 2 are true
String class is mutable, but String objects are immutable.
Both String class & String objects are immutable. Immutable means, you can't change its values or definition.
Immutable class : means you can't inherit that class. That is the final definition for that class, no body can change it.
Immutable object : means you can't change the state of an object. That is, you can't change the value of any instance variables once object is initialized.
Back To Top