/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main
(String[] args
) { System.
out.
println(contadorDeVirgulas
("30,60,90")); }
public static int contadorDeVirgulas
(String parametroComVirgula
) { int count = 0;
//método que separa as strings de acordo com padrão que vc deseja, no seu caso, a vírgula
parametroSeparado = parametroComVirgula.split(",", 100);
//parametroSeparado.length retorna o tamanho do array de String após a remoção das vírgulas
//o -1 foi usado para retirar da contagem o primeiro valor (30), pois não há vírgula antes dele
count = parametroSeparado.length - 1;
//retorno do contador
return count;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKCQlTeXN0ZW0ub3V0LnByaW50bG4oY29udGFkb3JEZVZpcmd1bGFzKCIzMCw2MCw5MCIpKTsKCX0KCQoJcHVibGljIHN0YXRpYyBpbnQgY29udGFkb3JEZVZpcmd1bGFzIChTdHJpbmcgcGFyYW1ldHJvQ29tVmlyZ3VsYSkgewoJCVN0cmluZ1tdIHBhcmFtZXRyb1NlcGFyYWRvOwoJCWludCBjb3VudCA9IDA7CgkJCgkJLy9tw6l0b2RvIHF1ZSBzZXBhcmEgYXMgc3RyaW5ncyBkZSBhY29yZG8gY29tIHBhZHLDo28gcXVlIHZjIGRlc2VqYSwgbm8gc2V1IGNhc28sIGEgdsOtcmd1bGEKCQlwYXJhbWV0cm9TZXBhcmFkbyA9IHBhcmFtZXRyb0NvbVZpcmd1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