答案:参考答案:参考代码import java.util.Scanner;public class countChar {public static void main(String[] args) {//输入需要检测的字符串System.out.print("Input String :");Scanner str0 = new Scanner(System.in);String s = str0.next();System.out.println("the String is :" s);s = s.toLowerCase(); //将字符串转换为小写//输入需要统计的字符System.out.print("Input char :");Scanner str1 = new Scanner(System.in);String s1 = str1.next();char c = s1.charAt(0);System.out.println("Input char is :" c);int count = 0; //统计出现次数变量for (int i = 0; i < s.length(); i ) {char ch = s.charAt(i);if (ch == c) {count ;}}System.out.println("The times is :" count);}}