swap string java

substring() StringBuffer Example

java.lang.StringBuffer class comes with many methods to manipulate string. One of the methods is overloaded substring() method used to extract part of the characters present in the buffer. What Java API says about substring() StringBuffer: public synchronized java.lang.String substring(int index1): Returns a string with the characteres of StringBuffer starting from…