如果string参数作为该对象中的子字符串出现一次或多次,则它返回最后出现的第一个字符的索引,如果没找到,则返回-1。
这是此方法的语法-
public int lastIndexOf(String str)
这是参数的详细信息-
str - 一个字符串。
import java.io.*; public class Test { public static void main(String args[]) { String Str=new String("Welcome to Learnfk.com"); String SubStr1=new String("Learnfk" ); System.out.print("Found Last Index :" ); System.out.println( Str.lastIndexOf( SubStr1 )); } }
这将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/java/java-string-lastindexof-str.html
来源:LearnFk无涯教程网
Found Last Index :11
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)