1.时间
作业题:
1.子串在字符串中出现的次数
import java.util.Scanner;
/**
* 分别在控制台输⼊字符串和⼦字符
* 串,并计算字符串中⼦字符串出现的
* 次数。indexOf(subs,n)
*/
public class H5 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str=sc.next();
String subs=sc.next();
int i=0;
int count=0;
while((i=str.indexOf(subs, i ))!=-1) {
count++;
i=i+1;
}
System.out.println("子串出现次数"+count);
}
}
2.
快捷键
1.ctrl alt v
2. ctrl f12 看本类的方法
3.按alt enter 对报错的有奇用
4.ctrl win 箭头 桌面进行滑动