The java.lang.StringBuffer.appendCodePoint(int cp)is the method which appends the string representation of the codePoint argument to this sequence.
Syntax :
public StringBuffer appendCodePoint(int cp)
Parameters : The method accepts a single parameter cp of integer type and refers to the Unicode code point.
Return Value : The method returns this object after appending the string represented by the codepoint.
Examples :
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); } } |
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); } } |
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); } } |
String buffer = Geeksforgeeks After appending CodePoint is = Geeksforgeeks+
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- StringBuilder appendCodePoint() method in Java with Examples
- StringBuffer deleteCharAt() Method in Java with Examples
- StringBuffer delete() Method in Java with Examples
- StringBuffer replace() Method in Java with Examples
- StringBuffer reverse() Method in Java with Examples
- StringBuffer append() Method in Java with Examples
- StringBuffer codePointCount() method in Java with Examples
- StringBuffer codePointBefore() method in Java with Examples
- StringBuffer trimToSize() method in Java with Examples
- StringBuffer toString() method in Java with Examples
- StringBuffer codePointAt() method in Java with Examples
- StringBuffer ensureCapacity() method in Java with Examples
- StringBuffer offsetByCodePoints() method in Java with Examples
- StringBuffer setCharAt() method in Java with Examples
- StringBuffer getChars() method in Java with Examples
- StringBuffer indexOf() method in Java with Examples
- StringBuffer substring() method in Java with Examples
- StringBuffer lastIndexOf() method in Java with Examples
- Matcher appendTail(StringBuffer) method in Java with Examples
- Matcher appendReplacement(StringBuffer, String) method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

