String x="a"; String xy=x+"b"; String ab="ab";
String x="a"; // "a" will be created in the constant pool referenced by x String xy=x+"b"; // this will be computed in Runtime and created in the constant pool with value as ab referenced by xy String ab="ab"; //this will be created in the constant pool referenced by ab
Quote:Note: The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation.
.equals()
Quote:String xy=x+"b"; // this will be computed in Runtime and created in the constant pool with value as ab referenced by xy
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)