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
如果觉得《Java查找字符串最后一次出现的位置》对你有帮助,请点赞、收藏,并留下你的观点哦!