代码
提交代码
public class StringDemo2 { public static void main(String[] args) { String str = "I love Java, I love imooc!"; int i = str.indexOf("love"); System.out.println("子串love在字符串str第一次出现的位置为:" + i); } }
运行结果