Code for Program to show an example of extraction of characters from a StringBuffer objects in Java
publicclass JAVA_060
{
publicstaticvoid main(String[] args)
{
StringBuffer SB=new StringBuffer("Many hands make light work");
System.out.println("StringBuffer : " + SB);
System.out.println("Character at position 0 is : " + SB.charAt(0));
System.out.println("Character at position 5 is : " + SB.charAt(5));
System.out.println("Character at position 10 is : " + SB.charAt(11));
char[] cArray=newchar[10];
SB.getChars(5,15,cArray,0);
System.out.println("The contents of cArray are : ");
for(int i=0;i<cArray.length;i++)
System.out.println(cArray[i]);
}
}