indexOf(String str) 函数和 lastIndexOf(String str) 函数都是String类中的函数,都是查找函数,查找str在字符串中出现的位置
一、indexOf(String str) 函数用法:
public class T {
public static void main(String[] args) {
String m = "Iamastudent";
System.out.println(m.indexOf("I"));
System.out.println(m.indexOf("Iam"));
System.out.println(m.indexOf("i"));
}
}