java.lang.StringBuilder appendCodePoint()
Description
On this document we will be showing a java example on how to use the appendCodePoint() method of StringBuilder Class. Basically appendCodePoint method Appends the string representation of the codePoint argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by Character.charCount(codePoint).
Method Syntax
public StringBuilder appendCodePoint(int codePoint)
Method Argument
Data Type | Parameter | Description |
---|---|---|
int | codePoint | a Unicode code point |
Method Returns
The appendCodePoint() method returns a reference to this object.
Compatibility
Requires Java 1.5 and up
Java StringBuilder appendCodePoint() Example
Below is a java code demonstrates the use of appendCodePoint() method of StringBuilder class. The example presented might be simple however it shows the behavior of the appendCodePoint() method.
package com.javatutorialhq.java.examples; import java.util.Scanner; /* * A java example source code to demonstrate * the use of appendCodePoint() method of StringBuilder class */ public class StringBuilderAppendCodePointExample { public static void main(String[] args) { // initialize our StringBuilder StringBuilder sb = new StringBuilder("test string : "); // ask for user input System.out.print("Enter a code point:"); Scanner s = new Scanner(System.in); String input = s.nextLine(); s.close(); // convert the string input to integer Integer codepoint = Integer.parseInt(input); // append the codepoint to our StringBuilder sb.appendCodePoint(codepoint); // print the contents of our StringBuilder System.out.println(sb); } }