It was an interview question. I was asked to implement the StringBuffer append function. I saw the code after the interview. But I cannot understand how the operation is done with creation of a single object.
I am thinking like this.
String s = "orange";
s.append("apple");
Here two objects are created.
But
StringBuilder s = new StringBuilder("Orange");
s.append("apple");
Now here only one object is created.
How is Java doing this operation?