public class lianxi3_ {
public int counter(String input, String word) {
int counter = 0;
String[] i = input.split("");
for (int j = 0; j < i.length; j++) {
if (i[j].equals(word)) {
counter++;
}
}
return counter;
}
}
import java.util.*;
public class lianxi3 {
<span style="white-space:pre"> </span>public static void main(String[] args) {
<span style="white-space:pre"> </span>lianxi3_ l = new lianxi3_();
<span style="white-space:pre"> </span>Scanner input = new Scanner(System.in);
<span style="white-space:pre"> </span>System.out.println("请输入一个字符串:");
<span style="white-space:pre"> </span>String name = input.next();
<span style="white-space:pre"> </span>System.out.println("请输入要查找的字符:");
<span style="white-space:pre"> </span>String n = input.next();
<span style="white-space:pre"> </span>int s = l.counter(name, n);
<span style="white-space:pre"> </span>System.out.println(name + "中包含" + s + "个" + n);
<span style="white-space:pre"> </span>}
}
public class lianxi3_ { public int counter(String input, String word) { int counter = 0; String[] i = input.split(""); for (int j = 0; j < i.length; j++) { if (i[j].equals(word)) { count