Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java String codePointCount() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ myStr = "Hello";3Order
Put the learning moves in the order that makes the concept easiest to apply.
The codePointCount() method returns the number of Unicode values found in a string.
Definition and Usage
Java String codePointCount() Method
❮ String Methods
Example
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);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 |