fork download
  1. class Main {
  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. }
  15.  
  16. //https://pt.stackoverflow.com/q/106096/101
Success #stdin #stdout 0.09s 32504KB
stdin
Standard input is empty
stdout
2