class Ideone {
public static void main
(String[] args
) { System.
out.
println(countVirgulas
("30,60,90")); }
static int countVirgulas
(String parametro
) { int count = 0;
for (char caractere : parametro.toCharArray()) {
if (caractere == ',') {
count++;
}
}
return count;
}
}
Y2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJU3lzdGVtLm91dC5wcmludGxuKGNvdW50VmlyZ3VsYXMoIjMwLDYwLDkwIikpOwoJfQogICAgc3RhdGljIGludCBjb3VudFZpcmd1bGFzKFN0cmluZyBwYXJhbWV0cm8pIHsKICAgIAlpbnQgY291bnQgPSAwOwogICAgICAgIGZvciAoY2hhciBjYXJhY3RlcmUgOiBwYXJhbWV0cm8udG9DaGFyQXJyYXkoKSkgewogICAgICAgICAgICBpZiAoY2FyYWN0ZXJlID09ICcsJykgewogICAgICAgICAgICAgICAgY291bnQrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gY291bnQ7CiAgICB9Cn0=