Replace value in StringBuffer - Java Language Basics

Java examples for Language Basics:StringBuffer

Description

Replace value in StringBuffer

Demo Code


public class Main {
 
  public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("Hello World");
    System.out.println("Original Text : " + sb);
    sb.replace(0,5,"Hi");
    System.out.println("Replaced Text : " + sb);
  }//from   w w  w.  ja  v a2  s. c o m
}

Result


Related Tutorials