Tutorials References Exercises Videos Menu
Paid Courses Website NEW Pro NEW

Java Tutorial

Java HOME Java Intro Java Get Started Java Syntax Java Output Java Comments Java Variables Java Data Types Java Type Casting Java Operators Java Strings Java Math Java Booleans Java If...Else Java Switch Java While Loop Java For Loop Java Break/Continue Java Arrays

Java Methods

Java Methods Java Method Parameters Java Method Overloading Java Scope Java Recursion

Java Classes

Java OOP Java Classes/Objects Java Class Attributes Java Class Methods Java Constructors Java Modifiers Java Encapsulation Java Packages / API Java Inheritance Java Polymorphism Java Inner Classes Java Abstraction Java Interface Java Enums Java User Input Java Date Java ArrayList Java LinkedList Java HashMap Java HashSet Java Iterator Java Wrapper Classes Java Exceptions Java RegEx Java Threads Java Lambda

Java File Handling

Java Files Java Create/Write Files Java Read Files Java Delete Files

Java How To

Add Two Numbers

Java Reference

Java Keywords Java String Methods Java Math Methods

Java Examples

Java Examples Java Compiler Java Exercises Java Quiz Java Certificate


Java String codePointCount() Method

❮ String Methods


Example

Return the number of Unicode values found in a string:

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

Try it Yourself »


Definition and Usage

The codePointCount() method returns the number of Unicode values found in a string.

Use the startIndex and endIndex parameters to specify where to begin and end the search.

The index of the first character is 0, the second character is 1, and so on.


Syntax

public int codePointCount(int startIndex, int endIndex)

Parameter Values

Parameter Description
startIndex An int value, representing the index to the first character in the string
endIndex An int value, representing the index after the last character in the string

Technical Details

Returns: An int value, representing the number of Unicode values found in a string
Throws: IndexOutOfBoundsException - if startIndex is negative, or endindex is larger than the length of the string, or startIndex is larger than endIndex
Java Version: 1.5

❮ String Methods