The problem may be silly, but I couldn’t find an answer on google.
Question : Is there any method in StringBuffer or StringBuilder or String itself, which does the same as subString(int startIndex, int endIndex), but modifies the original String ?
For example :
StringBuffer testString = new StringBuffer ("myTestString");
StringBuffer subString = testString.newSubStringMethod(0,1);
Sysout(testString);
Sysout(subString);
The output I wish to be printed is:
TestString
my
If not, what are things to be taken care, when we implement our own implementation of such a method.
You can achieve similar result with StringBuffer#delete or StringBuilder#delete