/* 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
{
static int buscaChar
(String text,
char c,
int n
) { int count = 0;
for (int i = 0; i < text.length() - 1; i++) {
if (text.charAt(i) == c) {
count = count + 1;
if (count == n)
return i;
}
}
return -1;
}
{
String textCopy
= "A linguagem processing e a mais divertida.";
int test = buscaChar(textCopy, 'a', 4);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXN0YXRpYyBpbnQgYnVzY2FDaGFyKFN0cmluZyB0ZXh0LCBjaGFyIGMsIGludCBuKSB7CgkJaW50IGNvdW50ID0gMDsKCQlmb3IgKGludCBpID0gMDsgaSA8IHRleHQubGVuZ3RoKCkgLSAxOyBpKyspIHsKCQkJaWYgKHRleHQuY2hhckF0KGkpID09IGMpIHsKCQkJCWNvdW50ID0gY291bnQgKyAxOwoJCQkJaWYgKGNvdW50ID09IG4pCgkJCQkJcmV0dXJuIGk7CgkJCX0KCQl9CgkJcmV0dXJuIC0xOwoJfQoJCglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTdHJpbmcgdGV4dENvcHkgPSAiQSBsaW5ndWFnZW0gcHJvY2Vzc2luZyBlIGEgbWFpcyBkaXZlcnRpZGEuIjsKCgkJaW50IHRlc3QgPSBidXNjYUNoYXIodGV4dENvcHksICdhJywgNCk7CgoJCVN5c3RlbS5vdXQucHJpbnRsbih0ZXN0KTsKCX0KfQ==