Java String.codePointAt(int index) example

By Yashwant Chavan, Views 35, Last updated on 02-Apr-2019

In this java tutorial, You will learn how to use codePointAt(int index) method of String class. This 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. If the char value specified at the given index is in the high-surrogate range, the following index is less than the length of this String, and the char value at the following index is in the low-surrogate range, then the supplementary code point corresponding to this surrogate pair is returned. Otherwise, the char value at the given index is returned.

tags Java

Returns the character (Unicode code point) at the specified index.

Syntax

public int codePointAt(int index)

Parameters

index - the index of the char value.

Returns

The code point value of the character at the index.

Throws

IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string.

Java String codePointAt(int index) example

  • Assign String value.
  • value.codePointAt(9);It will return the code point value of the string value at index 9.
  • Print the code point value.
package com.technicalkeeda;

public class App {

    public static void main(String[] args) {

        String value = "Technicalkeeda";

        int result = value.codePointAt(9);

        System.out.println("Code point value at the index 9 :- " + result);
    }
}

output

Code point value at the index 9 :- 107

Suggested Posts

Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]