/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner s
= new Scanner
(System.
in);
System.
out.
println("Insira uma frase e/ou palavras: ");
System.
out.
println("Selecione uma palavra a ser verificada na cadeia: "); String palavra
= s.
nextLine();
int contador = 0;
int posicao = cadeia.indexOf(palavra);
while (posicao != -1){
contador++;
posicao = cadeia.indexOf(palavra, posicao + palavra.length());
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU2Nhbm5lciBzID0gbmV3IFNjYW5uZXIgKFN5c3RlbS5pbik7CgogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiSW5zaXJhIHVtYSBmcmFzZSBlL291IHBhbGF2cmFzOiAiKTsKICAgICAgICBTdHJpbmcgY2FkZWlhID0gcy5uZXh0TGluZSgpOwoKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlNlbGVjaW9uZSB1bWEgcGFsYXZyYSBhIHNlciB2ZXJpZmljYWRhIG5hIGNhZGVpYTogIik7CiAgICAgICAgU3RyaW5nIHBhbGF2cmEgPSBzLm5leHRMaW5lKCk7CgogICAgICAgIGludCBjb250YWRvciA9IDA7CiAgICAgICAgaW50IHBvc2ljYW8gPSBjYWRlaWEuaW5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