StringBuffer Class in Java
StringBuffer Class in Java
Overview
StringBuffer class
1
StringBuffer class
A String object is not modifiable once created (i.e.,
it is immutable).
2
StringBuffer Constructors
StringBuffer( )
StringBuffer st = new StringBuffer();
3
Some StringBuffer methods
int length( )
Returns the number of characters in the buffer
4
Some StringBuffer methods
StringBuffer append(ob)
5
Some StringBuffer methods
StringBuffer replace(s, f, str)
StringBuffer delete(s, f)
Deletes characters from s to f - 1
StringBuffer sb=new StringBuffer(“Hello world”);
Sb.delete(0,2);
System.out.println(sb);
llo
StringBuffer deleteCharAt(i)
Deletes the character at i
StringBuffer sb=new StringBuffer(“Hello world”);
Sb.delete(2);
System.out.println(sb);
Helo
6