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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM