package com.qf.chapter02;
public class TestStringSearch {
public static void main(String[] args) {
String string="hello world ,java is the best in the world";
int lastIndex=string.lastIndexOf("world");//字符串第一个字符最后出现的下标
if(lastIndex==-1) {
System.out.println("不存在字符串 world");
}else {
System.out.println("字符串world最后一次出现的位置:"+lastIndex);
}
}
}
字符串world最后一次出现的位置:37
版权声明:本文为qq_57987156原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。