Java文字列codePointCount()メソッド
例
文字列で見つかったUnicode値の数を返します。
String myStr = "Hello";
int result = myStr.codePointCount(0, 5);
System.out.println(result);
定義と使用法
このcodePointCount()
メソッドは、文字列で見つかったUnicode値の数を返します。
startIndexパラメーターとendIndexパラメーターを使用して、検索を開始および終了する場所を指定します。
最初の文字のインデックスは0、2番目の文字のインデックスは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 Unicode値の数を表す値 |
---|---|
スロー: | IndexOutOfBoundsException -startIndexが負の場合、endindexが文字列の長さより大きい場合、またはstartIndexがendIndexより大きい場合 |
Javaバージョン: | 1.5 |
❮文字列メソッド