-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
  • 40,646
  • 13
  • 77
  • 103

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,805
  • 19
  • 81
  • 156