长沙网站优化技巧,北京中国建设工程造价管理协会网站,安全员考试报名官网,网站做视频的软件有哪些查找指定字符或字符串在字符串中第一次出现地方的索引#xff0c;未找到的情况返回 -1.
例如
String.indexOf(String str)
String str1“012345”; String str2“23”; System.out.println( str1.indexOf(str2) ); 输出结果#xff1a;2。
重载方法有
String.indexOf(St…查找指定字符或字符串在字符串中第一次出现地方的索引未找到的情况返回 -1.
例如
String.indexOf(String str)
String str1“012345”; String str2“23”; System.out.println( str1.indexOf(str2) ); 输出结果2。
重载方法有
String.indexOf(String strint index)
从index的地方开始找返回第一次出现的索引
String str1“012345012345”; String str2“23”; System.out.println( str1.indexOf(str2,5) ); 输出结果8.