String is immutable

Someone asked me an interesting question. String is immutable. So how can we reassign a value to a string variable? Example of string immutable

The computer allocates memory to store John in firstname. When Matt is assigned to the same string, the computer finds a different space in memory to store Matt. Thereafter, space […]