Java.lang.StringBuffer.codePointAt() Method


Advertisements


Description

The java.lang.StringBuffer.codePointAt() method returns the character (Unicode code point) at the specified index.The index refers to char values (Unicode code units) and ranges from 0 to length() - 1.

Declaration

Following is the declaration for java.lang.StringBuffer.codePointAt() method

public int codePointAt(int index)

Parameters

  • index -- This is the index to the char values.

Return Value

This method returns the code point value of the character at the index.

Exception

  • NA

Example

The following example shows the usage of java.lang.StringBuffer.codePointAt() method.

package com.tutorialspoint;

import java.lang.*;

public class StringBufferDemo {

   public static void main(String[] args) {
  
   StringBuffer buff = new StringBuffer("TUTORIALS");
   System.out.println("buffer = " + buff);

   // returns the codepoint at index 5
   int retval = buff.codePointAt(5);
   System.out.println("Character(unicode point) = " + retval);
    
   buff = new StringBuffer("amrood admin ");
   System.out.println("buffer = " + buff);
   // returns the codepoint at index 6 i.e whitespace character
   retval = buff.codePointAt(6);
   System.out.println("Character(unicode point) = " + retval);
   }
}

Let us compile and run the above program, this will produce the following result:

buffer = TUTORIALS
Character(unicode point) = 73
buffer = amrood admin
Character(unicode point) = 32

java_lang_stringbuffer.htm

Advertisements