for循环改为foreach该怎么改??
import java.util.Scanner;
public class Lianxi {
public static void main(String[] args){
Scanner input =new Scanner(System.in);
System.out.println("请输入您想输入的字符串");
String s=input.next();
int num=0;
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='a')
num++;
}
System.out.println(num);
}
}