Get StringBuffer SubString - Java Language Basics

Java examples for Language Basics:StringBuffer

Description

Get StringBuffer SubString

Demo Code


public class Main {

  public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("Java StringBuffer SubString test");
    System.out.println("Original Text : " + sb);

    String strPart1 = sb.substring(5);
    System.out.println("Substring 1 : " + strPart1);

    String strPart2 = sb.substring(0, 17);
    System.out.println("Substring 2 : " + strPart2);

  }//from  w w  w.j a  v  a2s  . co m
}

Result


Related Tutorials