Java 實例 - 查找字符串最后一次出現的位置


 

package string;

public class lastIndexString {
public static void main(String[] args) {
/**
* 
*/
String str="hello I am ZHUXIAOPANG,welcomg to my blog,I think my blog will be better,hello blog";
int lastindex =str.lastIndexOf("blog");
if (lastindex == -1) {
System.out.println("沒有找到字符串最后出現的位置");
} else {
System.out.println("字符串最后出現的位置在"+lastindex);
}
}
}

最后輸出結果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM