Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

codePointCount()

Example

“Provide the count of Unicode characters present within a string.”

String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);

Definition and Usage

The codePointCount() method calculates the quantity of Unicode values within a string, allowing you to define the starting and ending points of the search using the startIndex and endIndex parameters. Remember, indexing begins at 0 for the first character, 1 for the second character, and so forth.

Syntax

public int codePointCount(int startIndex, int endIndex)

Parameter Values

Parameter

Description

startIndex

An integer value representing the index of the first character in the string.

endIndex

An integer value representing the index immediately after the last character in the string.

Technical Details

Returns

“An integer value representing the count of Unicode characters present in a string.”

Throws

“IndexOutOfBoundsException is thrown if the startIndex is negative, or if the endIndex exceeds the length of the string, or if the startIndex is greater than the endIndex.”

Java Version

1.5