Java查找字符串最后一次出现的位置
字符串函数 strOrig.lastIndexOf(Stringname) 查找子字符串 Stringname 在 strOrig 出现的位置
SearchlastString.java 文件
public class SearchlastString {
public static void main(String[] args) {
String strOrig = "Hello world ,Hello facesoho";
int lastIndex = strOrig.lastIndexOf("facesoho");
if(lastIndex == - 1){
System.out.println("No find string facesoho");
}else{
System.out.println("facesoho last postion:" + lastIndex);
}
}
}
public static void main(String[] args) {
String strOrig = "Hello world ,Hello facesoho";
int lastIndex = strOrig.lastIndexOf("facesoho");
if(lastIndex == - 1){
System.out.println("No find string facesoho");
}else{
System.out.println("facesoho last postion:" + lastIndex);
}
}
}
以上代码实例输出结果为:
facesoho last postion:19
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题