Java examples for Language Basics:StringBuffer
How to set length of StringBuffer using setLength method of StringBuffer class in Java.
public class Main { //from ww w .j a v a2s .co m public static void main(String[] args) { StringBuffer sbf = new StringBuffer("StringBuffer setLength method example"); sbf.setLength(12); System.out.println("StringBuffer contents: " + sbf); sbf.setLength(0); System.out.println("StringBuffer contents deleted:" + sbf); } }