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 (int i = 0; i < parametro.length(); i++) {
  8. if (parametro.charAt(i) == ',') {
  9. count++;
  10. }
  11. }
  12. return count;
  13. }
  14. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
2