.codePointCount()
Published Jul 23, 2021Updated Oct 5, 2021
Contribute to Docs
Returns the number of Unicode values in specified range of a string.
Syntax
string.codePointCount(int indexStart, int indexEnd)
indexStart
(required): The index of the first character in the string to start counting from.indexEnd
(required): One more than the index of the last character in the string to stop counting at.
Example 1
Print the number of Unicode values in the string "Hello World"
:
class CountUnicodeValues {public static void main(String[] args) {String s = "Hello World";System.out.println(s.codePointCount(0, 10));// Output: 10}}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly17 hours