首页 > 其他 > 详细

查找字符串最后一次出现的位置

时间:2019-09-20 00:31:08      阅读:98      评论:0      收藏:0      [点我收藏+]

以下实例中我们通过字符串函数 strOrig.lastIndexOf(Stringname) 来查找子字符串 Stringname 在 strOrig 出现的位置:

也可以从前向后遍历数据,判断里面strOrig[i]=="Runoob",i++;

String strOrig = "Hello world ,Hello Runoob";

int lastIndex = strOrig.lastIndexOf("Runoob").;

if(lastIndex == - 1)

{

System.out.println("没有找到字符串 Runoob"); }

else

{

System.out.println("Runoob 字符串最后出现的位置: "+ lastIndex);

}

查找字符串最后一次出现的位置

原文:https://www.cnblogs.com/onetheway2018/p/11553016.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!