indexOf(int);
String str = "https://www.baidu.com";
int target = str.indexOf('w');
System.out.println(target);
输出结果为:
8
h t t p s : / / w w w . b a i d u . c o m
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
indexOf(int)输出int值在字符串的索引位置。
indexOf(String str, int fromIndex)从formIndex(索引位置)开始向后查找str开始的索引,并返回索引结果。