java.lang.StringBuffer.appendCodePoint(int cp) is the method to append the string representation of the codePoint parameter to the sequence.
Syntax :
public StringBuffer appendCodePoint(int cp)
Parameters :
Input: StringBuffer = Apple int cp = 65 Output: AppleA Input: StringBuffer = GeeksforGeeks int cp = 156 Output: GeeksforGeeks? Explanation: Because 65 is the ASCII value for 'A' and 156 is the ASCII value for '?'
Below programs illustrate the java.lang.StringBuffer.appendCodePoint(int cp) method:
Program 1:
// Java praogram to illustrate the // java.lang.StringBuffer.appendCodePoint(int cp) import java.lang.*; public class Geeks { public static void main(String[] args) { StringBuffer sbf = new StringBuffer("Geeksforgeeks"); System.out.println("String buffer = " + sbf); // Here it appends the CodePoint as // String to the string buffer sbf.appendCodePoint(65); System.out.println("After appending CodePoint is = " + sbf); } }
Output:
String buffer = Geeksforgeeks After appending CodePoint is = GeeksforgeeksA
Program 2:
// Java praogram to illustrate the // java.lang.StringBuffer.appendCodePoint(int cp) import java.lang.*; public class Geeks { public static void main(String[] args) { StringBuffer sbf = new StringBuffer("Geeksforgeeks"); System.out.println("String buffer = " + sbf); // Here it appends the CodePoint as // string to the string buffer sbf.appendCodePoint(54); System.out.println("After appending CodePoint is = " + sbf); } }
Output:
String buffer = Geeksforgeeks After appending CodePoint is = Geeksforgeeks6
Program 3:
// Java praogram to illustrate the // java.lang.StringBuffer.appendCodePoint(int cp) import java.lang.*; public class Geeks { public static void main(String[] args) { StringBuffer sbf = new StringBuffer("Geeksforgeeks"); System.out.println("String buffer = " + sbf); // Here it appends the CodePoint as // string to the string buffer sbf.appendCodePoint(43); System.out.println("After appending CodePoint is = " + sbf); } }
Output:
String buffer = Geeksforgeeks After appending CodePoint is = Geeksforgeeks+
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.