-2

when we write String str="mac"; and again we can initialize with str="joe"; why this happens when String is immutable where we can initialize only once for immutable object

Subhrajyoti Majumder
  • 39,719
  • 12
  • 74
  • 101

1 Answers1

2

String object is immutable, so you cannot modify its content. But you can reassign string variable to different String object.

Leos Literak
  • 8,186
  • 16
  • 70
  • 132