- package hi87;
- import java.util.Scanner;
- public class hi788 {
- static Scanner keyboard = new Scanner(System.in);
- public static void main(String args[]) {
- int b = 0;
- System.out.print("Input a string");
- String a=keyboard.next();
-
- System.out.print(a+" has "+f(a)+" As");
- }
-
- static int f(String str) {
- if(str.equals (""))
- {
- return 0;
- }
- else if(str.substring(0,1).equals ("A"))
- {
- return 1+f(str.substring(1));
- }
- else
- {
- return f(str.substring(1));
- }
- }
- }
複製代碼 |