String的lastIndexOf()用于获取字符串中某个子字符串最后一次出现的位置

String还定义有lastIndexOf(String str,int from) 意思为str在字符串多次出现时将返回最后一次出现的位置。

eg: String str = "I can because i think i can";

        int index = str.lastIndexOf("can")

        System.out.println(index); // 24

原文地址:https://www.cnblogs.com/sunfenqing/p/7457459.html