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 // assign a value to a string variable string firstname = “John”; // string has immutability, but we can still change the value? how? firstname = “Matt”; The computer allocates memory […]