StringBuilder appendCodePoint() method in Java with Examples
Last Updated :
13 Dec, 2021
The appendCodePoint(int codePoint) method of StringBuilder class is the inbuilt method used to append the string representation of the codePoint argument to this sequence.
The argument is appended to this StringBuilder content and length of the object is increased by Character.charCount(codePoint). The effect is the same as if the int value in parameter is converted to a char array and the character in that array were then appended to this character sequence.
Syntax:
public StringBuilder appendCodePoint(int codePoint)
Parameters: This method accepts only one parameter codePoint which is int type value refers to a Unicode code point.
Return Value: This method returns reference to this object.
Below programs illustrate the java.lang.StringBuilder.appendCodePoint() method:
Example 1:
Java
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
StringBuilder
str
= new StringBuilder("GeeksforGeeks");
System.out.println("StringBuilder = "
+ str);
str.appendCodePoint( 67 );
System.out.println("Modified StringBuilder = "
+ str);
}
}
|
Output:
StringBuilder = GeeksforGeeks
Modified StringBuilder = GeeksforGeeksC
Example 2:
Java
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
StringBuilder
str
= new StringBuilder("GeeksforGeeks");
System.out.println("StringBuilder = "
+ str);
str.appendCodePoint( 44 );
System.out.println("Modified StringBuilder = "
+ str);
}
}
|
Output:
StringBuilder = GeeksforGeeks
Modified StringBuilder = GeeksforGeeks,
References: https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#appendCodePoint(int)
Share your thoughts in the comments
Please Login to comment...