热门搜索 :
考研考公
您的当前位置:首页正文

java 常用类-String

来源:伴沃教育

1.string.indexOf(str);

  查找指定字符串在string中的第一次出现的索引。未找到返回-1.

String str1="012345";
String str2="23";
System.out.println( str1.indexOf(str2) );//2

2.string。indexOf(string str,int index);

  从索引index位开始,查找str在string中的索引位置。

String str1="012345012345";
String str2="23";
System.out.println( str1.indexOf(str2,5) );//8

转载于:https://www.cnblogs.com/leizz/p/11563343.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Top