Javatpoint Logo
Javatpoint Logo

Java Character codePointCount() Method

This Method has 2 types of syntax.

Java Character codePointCount(char[]a, int offset, int count) Method

The codePointCount(char[]a, int offset, int count) method is used to return the number of Unicode code points in the sub array of the char array. The offset argument is the index of the first char in the given char array and the count argument indicates the length of the sub array.

Syntax

Parameter

The above method requires three parameters:

  • The char array.
  • The offset is the index of the first char in the given char array.
  • The count is the length of the sub array in the given char.

Return Value

This method returns the number of Unicode code point in the specified sub array.

Example 1

Test it Now

Output:

Welcome to our tutorial site:
The result is given as: 2

Example 2

Test it Now

Output:

The alphabets are: 'a', 'b', 'c', 'd', 'e'
The number of Unicode code point for alphabets are 4
The numbers are:  '1', '2', '3', '4', '5'
The number of Unicode code point for numbers are 3

Example 3

Test it Now

Output:

Hello everyone
6 is generated because method counts the first argument.
Everyday is a fun day
2 is generated because method counts the second argument.

Java Character codePointCount()Method

The codePointCount(CharSequence seq, int beginIndex, int endIndex) method of Character class is used to return the number of Unicode code points in the text range of a particular char sequence. The text range begins from the beginIndex and ends at endIndex.

Syntax

Parameter

The above method requires three parameters:

  • The char sequence.
  • The beginIndex is the index to the first char of the text range.
  • The endIndex is the index after the last char of the text range.

Return Value

The codePointCount(CharSequence seq, int beginIndex, int endIndex) method returns the number of Unicode code points in the specified text range.

Example 4

Test it Now

Output:

This is a unique example!
The result comes to be:25

Example 5

Test it Now

Output:

This is a unique example!
The result comes to be:25
Hello World!
Number of Unicode code points is 4

Example 6

Test it Now

Output:

This is a unique example!
The result comes to be: 25
Java is a high level language!
The result comes to be: 30
Java is based on the cocepts of OOPS!
The result comes to be: 37
Next TopicJava Character



Help Others, Please Share

facebook twitter pinterest