Java文字列codePointBefore()メソッド
例
文字列の最初の文字のUnicodeを返します(「H」のUnicode値は72です)。
String myStr = "Hello";
int result = myStr.codePointBefore(1);
System.out.println(result);
定義と使用法
このcodePointBefore()
メソッドは、文字列内の指定されたインデックスの前の文字のUnicode値を返します。
最初の文字のインデックスは1、2番目の文字は2、というように続きます。
注:値0は負の数(到達不能)であるため、エラーが生成されます。
構文
public int codePointBefore(int index)
パラメータ値
Parameter | Description |
---|---|
index | An int value, representing the index
following the Unicode that should be returned |
技術的な詳細
戻り値: | 指定されたインデックスの前のint Unicode値を表す値 |
---|---|
スロー: | IndexOutOfBoundsException -インデックスが負の場合、または指定された文字列の長さ以上の場合 |
Javaバージョン: | 1.5 |
❮文字列メソッド