How to remove all values from StringBuffer - Java Language Basics

Java examples for Language Basics:StringBuffer

Description

How to remove all values from StringBuffer

Demo Code

 
public class Main {
       //  w ww  .j av  a 2 s  .  co m
        public static void main(String[] args) {
                StringBuffer sbf = new StringBuffer("Hello World!");
               
                System.out.println("StringBuffer content: " + sbf) ;
               
                sbf.delete(0, sbf.length());
               
                System.out.println("StringBuffer content after reset:" + sbf);
        }
}

Result


Related Tutorials