This example will use substring method of java StringBuffer class to get a substring of content of the StringBuffer.
Source Code
package com.beginner.examples;
public class JavaStringBufferSubString {
public static void main(String[] args) {
//create StringBuffer.
StringBuffer stringBuffer = new StringBuffer("Hello World !");
/*
* Use substring(int start) method to get the substring.
*/
String stringPart = stringBuffer.substring(6);
System.out.println(stringPart);
}
}
Output:
World !