3:53 pm - Wednesday March 24, 5706

StringBuffer code for append(char[]str,int offset,int len) in java

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
*
*@author:candidjava.com
*@description:StringBuffer code for append(char[] str,int offset,int len)in
*                           java
*/

public class StringBufferAppend

{
public static void main(String[] args) {

StringBuffer buff = new StringBuffer("candidjava");
System.out.println("Before append = " + buff);

char[] str = new char[] { 'a', 'd', 'm', 'i', 'n', 'i', 's', 't', 'r',
'a', 't', 'o', 'r' }; // char array

buff.append(str, 0, 5);/*
* appends the string representation of char
* array argument to this string buffer with
* offset at index 0 and length as 5
*/

System.out.println("After append = " + buff);// printing the string
// buffer after
// appending

}

}




OUTPUT:

Before append = candidjava
After append = candidjava admin

Filed in: Z-A All Java Codes

Comments are closed.