BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Java StringBuilder appendCodePoint()

By Chaitanya Singh | Filed Under: java

Java StringBuilder appendCodePoint(int codePoint) Method appends string representation of the specified code point to this sequence. In this guide, we will discuss appendCodePoint() method with examples.

Syntax of appendCodePoint():

sb.appendCodePoint(90);

The above statement would append character ‘Z’ (Unicode code point 90) at the end of the sequence represented by the object of StringBuilder class.

appendCodePoint() Description

public StringBuilder appendCodePoint(int codePoint): This method appends the string representation of the specified code point value at the end of the sequence represented by object of StringBuilder.

This specified unicode code point can represent more than one characters so the length of the sequence after this append operation would be:

Initial length of sequence (sb.length()) + Character.charCount(codePoint)

appendCodePoint() Parameters

This method takes a single parameter:

  • codePoint: A numeric value that represents a char array (string).

appendCodePoint() Return Value

  • It returns a StringBuilder instance that contains the newly added chars.

Example 1: Append char at the end

public class JavaExample {
  public static void main(String[] args) {
    StringBuilder sb = new StringBuilder("Ato");
    sb.appendCodePoint(90); //append 'Z'
    System.out.println(sb); //Print new Sequence
  }
}

Output:

Java StringBuilder appendCodePoint() Example Output_1

Example 2: Append Blush Smiley at the end of Sequence

public class JavaExample {
  public static void main(String[] args) {
    StringBuilder sb = new StringBuilder("Welcome");
    sb.appendCodePoint(128522); //append Blush Smiley
    System.out.println(sb);
  }
}

Output:

Java StringBuilder appendCodePoint() Example Output_2

Recommended Posts

  • Java StringBuilder codePointAt()
  • Java StringBuilder subSequence()
  • Java StringBuilder setCharAt()
  • Java StringBuilder deleteCharAt()

References: official docs

Java Tutorial

Java Introduction

  • Java Index
  • Java Introduction
  • History of Java
  • Features of Java
  • C++ vs Java
  • JDK vs JRE vs JVM
  • JVM - Java Virtual Machine
  • First Java Program
  • Variables
  • Data Types
  • Operators

Java Flow Control

  • Java If-else
  • Java Switch-Case
  • Java For loop
  • Java while loop
  • Java do-while loop
  • Continue statement
  • break statement

Java Arrays

  • Java Arrays

OOPs Concepts

  • OOPs Concepts
  • Constructor
  • Java String
  • Static keyword
  • Inheritance
  • Types of inheritance
  • Aggregation
  • Association
  • Super Keyword
  • Method overloading
  • Method overriding
  • Overloading vs Overriding
  • Polymorphism
  • Types of polymorphism
  • Static and dynamic binding
  • Abstract class and methods
  • Interface
  • Abstract class vs interface
  • Encapsulation
  • Packages
  • Access modifiers
  • Garbage Collection
  • Inner classes
  • Static import
  • Static constructor

Java Exception Handling

  • Exception handling
  • Java try-catch
  • Java throw
  • Java throws
  • Checked and Unchecked Exceptions
  • Jav try catch finally
  • Exception Examples
  • Exception Propagation

Collections Framework

  • Collections in Java
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Java HashSet
  • Java LinkedHashSet
  • Java TreeSet
  • Java HashMap
  • Java TreeMap
  • Java LinkedHashMap
  • Java Queue
  • Java PriorityQueue
  • Java Deque
  • Comparable interface
  • Comparator interface
  • Collections Interview Questions

MORE ...

  • Java Scanner Class
  • Java 8 Features
  • Java 9 Features
  • Java Conversion
  • Java Date
  • Java Multithreading
  • Java I/O
  • Java Serialization
  • Java Regex
  • Java AWT
  • Java Swing
  • Java Enum
  • Java Annotations
  • Java main method
  • Java Interview Q

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap