首页 > 技术文章 > String的lastIndexOf()用于获取字符串中某个子字符串最后一次出现的位置

sunfenqing 2017-08-31 11:28 原文

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

推荐阅读