I have appended some strBuild with some characters and putting that strBuild into stringBuildArr. then called the java.lang.StringBuilder.delete(int start, int end) function on strBuild.
Here is the issue not only this deletes the data from strBuild but also from stringBuildArr.
StringBuilder strBuild = new StringBuilder();
StringBuilder stringBuildArr[] = new StringBuilder[10];
strBuild.append("hgfd");
stringBuildArr[0] = strBuild;
System.out.println("Output1: "+stringBuildArr[0]);
strBuild.delete(0, strBuild.length());
System.out.println("Output2: "+stringBuildArr[0]);
RESULT
Output1: hgfd
Output2:
so, how does storage of these stringbuilder and stringbuffer class works?