Java-string-lastindexof-chfromindex
提供:Dev Guides
文字列lastIndexOf(int ch、int fromIndex)
説明
このメソッドは、このオブジェクトによって表される文字シーケンスでfromIndex以下である文字の最後の出現のインデックスを返します。文字がそのポイントの前に出現しない場合は-1を返します。
構文
このメソッドの構文は次のとおりです-
public int lastIndexOf(int ch, int fromIndex)
パラメーター
ここにパラメータの詳細があります-
- ch -文字。
- fromIndex -検索を開始するインデックス。
戻り値
- このメソッドはインデックスを返します。
例
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str = new String("Welcome to finddevguides.com");
System.out.print("Found Last Index :" );
System.out.println(Str.lastIndexOf( 'o', 5 ));
}
}
これは、次の結果を生成します-
出力
Found Last Index :4