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+"個數(shù)為:"+num);?????? }??????}
添加回答
舉報
0/150
提交
取消