fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static String[] names = new String[]{"Luke", "Jen", "Other", "OneMore", "Jake"};
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. char c = 'e';
  14. System.out.println(count(c));
  15. }
  16.  
  17. public static int count(char c) {
  18. int count = 0;
  19. for (String name : names) {
  20. if (name.charAt(name.length() - 1) == c) {
  21. count++;
  22. }
  23. }
  24. return count;
  25. }
  26. }
Success #stdin #stdout 0.06s 27540KB
stdin
Standard input is empty
stdout
3