查找字符串最后一次出现的位置

查找字符串最后一次出现的位置

public class SearchlastString {//查找字符串最后一次出现的位置

public static void main(String[] args) {

String strOrig = "Hello world ,Hello Runoob";

int lastIndex = strOrig.lastIndexOf("Runoob");

if(lastIndex == -1) {

System.out.println("没有找到字符串 Runoob");

}else {

System.out.println("Runoob 字符串最后出现的位置: "+ lastIndex);

}

}

}

 

posted @ 2021-10-07 19:30  慢漫曼蔓  阅读(281)  评论(0)    收藏  举报