Java Program that illustrate StringBuffer class & using different method like append, insert, capacity, lenth, charat etc.
Program
class stBuffercls
{
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Delhi");
//Length
System.out.println("Length of Buffer String:"+sb.length());
//Capacity
System.out.println("Capacity of Buffer String:"+sb.capacity());
//charAt
System.out.println("CharAt(3) from Buffer String:"+sb.charAt(3));
//Append
System.out.println("String After Append Operation:"+ sb.append(" Hai Meri Jaan"));
//Insert
sb.insert(0,"Yeh ");
System.out.println("String After insert operation:"+ sb);
}
}
No comments:
Post a Comment