Java 문자열 codePointCount() 메서드
예시
문자열에서 찾은 유니코드 값의 수를 반환합니다.
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
정의 및 사용
이 codePointCount()
메서드는 문자열에서 찾은 유니코드 값의 수를 반환합니다.
startIndex 및 endIndex 매개변수를 사용 하여 검색을 시작하고 종료할 위치를 지정하십시오.
첫 번째 문자의 인덱스는 0, 두 번째 문자는 1 등입니다.
통사론
public int codePointCount(int startIndex, int endIndex)
매개변수 값
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 |
기술적 세부 사항
보고: | int 문자열에서 찾은 유니코드 값의 수를 나타내는 값 |
---|---|
던짐: | IndexOutOfBoundsException - startIndex가 음수이거나 endindex가 문자열의 길이보다 크거나 startIndex가 endIndex보다 큰 경우 |
자바 버전: | 1.5 |
❮ 문자열 메서드