fork download
  1. import java.util.regex.Pattern;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. String str = "aaBBdf8k3AAadnklA";
  6. System.out.println(
  7. str
  8. .toLowerCase() // lowercase input String
  9. .chars() // get IntStream of all characters
  10. .filter(c -> c == 'a') // use filter to match only chosen characters
  11. .count()
  12. );
  13. }
  14. }
Success #stdin #stdout 0.08s 56144KB
stdin
Standard input is empty
stdout
6