Esempio | |
|
Soluzione |
Un oggetto String non costante deve essere invece dichiarato come StringBuffer. Tutte le modifiche a String devono essere eseguite con la classe append() di StringBuffer.
|
public class ClassA { private final String stringObject = "A new String"; private StringBuffer nonConstantString = new StringBuffer("Changing String"); public void method(){ String localString = "append"; nonConstantString.append(localString); } } |