append(x) in JAVA – JAVA 10th Class notes – ICSE JAVA Note

append(x) in JAVA – JAVA 10th Class notes – ICSE JAVA Notes

append(x ) :

append(x ) function lets you add String x at the end of the other String.

Syntax : str1.append(str2);

Example : StringBuffer str1 = new StringBuffer(“COMPUTER”);

StringBuffer str2 = new StringBuffer(“ APPLICATION”);

str1.append(str2);

 

Output : COMPUTER APPLICATION

 

/* Program to illustrate the function append() */

 

class Append

{

public static void main(String args[])

{

StringBuffer str1= new StringBuffer(“COMPUTER”);

System.out.println(” First String : ” + str1);

StringBuffer str2= new StringBuffer(” APPLICATION”);

System.out.println(” Second String : ” + str2);

str1.append(str2);

System.out.println(” String After Appending : ” + str1);

}

}

widthC! 9p n f solid black 1.0pt;mso-border-themecolor: text1;border-top:none;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor: text1;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;padding: 0in 5.4pt 0in 5.4pt;height:.3in’>

setCharAt(index,c)

delete(beg, end)

setLength(n)

reverse( )

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: