package sss;
public class qqq {
public int counter(String inputs, String word) {
int counter = 0;
String[] poop = new String[inputs.length()];
for (int i = 0; i < poop.length; i++) {
poop[i] = inputs.substring(i, i + 1);
}
for (int i = 0; i < poop.length; i++) {
if (poop[i].equals(word)) {
counter++;
}
}
return counter;
}
}
package sss;
import java.util.Scanner;
public class qqq1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("输入一个字符串");
String i = input.next();
System.out.println("输入查找的字符串");
String q = input.next();
qqq s = new qqq();
int t = s.counter(i, q);
System.out.println(i + "中包含" + t + "个" + q);
}
}