Domanda di colloquio di Goldman Sachs

Is a string mutable?

Risposte di colloquio

Anonimo

16 mag 2016

No

Anonimo

2 feb 2017

I'm assuming that "string" in this context means an instance of the Java String class. Even if it referred to an analogous structure in Python, C, or C++, the answer would still be No. If you want to modify a string in any one of those languages, you would first need to release that a string is just syntactic sugar for a char array. Convert your string to a char array, make your adjustments, and then convert back to a string.