fork(3) download
  1. class Ideone {
  2. public static void main (String[] args) {
  3. System.out.println(countVirgulas("30,60,90"));
  4. }
  5. static int countVirgulas(String parametro) {
  6. int count = 0;
  7. for (char caractere : parametro.toCharArray()) {
  8. if (caractere == ',') {
  9. count++;
  10. }
  11. }
  12. return count;
  13. }
  14. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
2