Java-string-lastindexof
提供:Dev Guides
Java – String lastIndexOf()メソッド
説明
このメソッドは、このオブジェクトによって表される文字シーケンスでfromIndex以下である文字の最後の出現のインデックスを返します。文字がそのポイントの前に出現しない場合は-1を返します。
構文
このメソッドの構文は次のとおりです-
int lastIndexOf(int ch)
パラメーター
ここにパラメータの詳細があります-
- ch -文字。
戻り値
- このメソッドはインデックスを返します。
例
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' ));
}
}
これは、次の結果を生成します-
出力
Found Last Index :27