import java.util.Scanner; public class Ex3_2 { public static void main(String afe[]){ String putIn = “The past is gone and static. Nothing we can do will change it. Thefuture is before us and dynamic. Everything we do will affect it.” char findChar,temp; int num = 0; Scanner input=new Scanner(System.in); System.out.println("请输入要查找的字符:"); findChar = input.next().charAt(0); for(int i = 0;i<putIn.length();i++){ temp = putIn.charAt(i); if(temp == findChar){ num++; } } System.out.println("字符串"+putIn+"中包含"+findChar+"个数为:"+num); } }
添加回答
举报
0/150
提交
取消