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 StringBuffer appendCodePoint() Method

By Chaitanya Singh | Filed Under: java

Java StringBuffer 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 StringBuffer class.

appendCodePoint() Description

public StringBuffer 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 StringBuffer.

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 StringBuffer instance that contains the newly added chars.

Example 1: Append a char using Unicode code point

public class JavaExample {
  public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("Zto");
    System.out.println("Old String: "+sb);
    sb.appendCodePoint(89); //append 'Y'
    System.out.println("New String: "+sb); //Print new Sequence
  }
}

Output:

Java StringBuffer appendCodePoint() Example Output_1

Example 2: Append Emoji to StringBuffer

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

Output:

Java StringBuffer appendCodePoint() Example Output_2

Example 3: Append Right Arrow

public class JavaExample {
  public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("Next ");
    sb.appendCodePoint(8594); //append right arrow
    System.out.println(sb);
  }
}

Output:

Java StringBuffer appendCodePoint() Example Output_3

Recommended Posts

  • Java StringBuffer append()
  • Append new line to StringBuffer
  • Java StringBuffer substring()
  • Java StringBuffer replace()
❮ Java StringBuffer

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