import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Exercicio1_string {
public static void main
(String[] args
) { char letra = ' ';
System.
out.
println("Escreva uma frase: "); try {
frase = cd.readLine();
System.
out.
println("Erro de entrada"); }
System.
out.
println("Escreva uma letra para encontrar na frase: "); try {
letra = cd.readLine().charAt(0);
System.
out.
println("Erro de entrada"); }
int contador = 0;
for (int caractere : frase.toCharArray()) if (caractere == letra) contador++;
if (contador
== 0) System.
out.
println("Nao existe a letra na frase"); else System.
out.
println("A letra aparece " + contador
+ " vezes"); }
}
//https://pt.stackoverflow.com/q/328104/101
aW1wb3J0IGphdmEuaW8uQnVmZmVyZWRSZWFkZXI7CmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwppbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbVJlYWRlcjsKCmNsYXNzIEV4ZXJjaWNpbzFfc3RyaW5nIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBJbnB1dFN0cmVhbVJlYWRlciBjID0gbmV3IElucHV0U3RyZWFtUmVhZGVyKFN5c3RlbS5pbik7CiAgICAgICAgQnVmZmVyZWRSZWFkZXIgY2QgPSBuZXcgQnVmZmVyZWRSZWFkZXIoYyk7CiAgICAgICAgU3RyaW5nIGZyYXNlID0gIiI7CiAgICAgICAgY2hhciBsZXRyYSA9ICcgJzsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVzY3JldmEgdW1hIGZyYXNlOiAiKTsKICAgICAgICB0cnkgewogICAgICAgICAgICBmcmFzZSA9IGNkLnJlYWRMaW5lKCk7CiAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVycm8gZGUgZW50cmFkYSIpOwogICAgICAgIH0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVzY3JldmEgdW1hIGxldHJhIHBhcmEgZW5jb250cmFyIG5hIGZyYXNlOiAiKTsKICAgICAgICB0cnkgewogICAgICAgICAgICBsZXRyYSA9IGNkLnJlYWRMaW5lKCkuY2hhckF0KDApOwogICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFcnJvIGRlIGVudHJhZGEiKTsKICAgICAgICB9CiAgICAgICAgaW50IGNvbnRhZG9yID0gMDsKICAgICAgICBmb3IgKGludCBjYXJhY3RlcmUgOiBmcmFzZS50b0NoYXJBcnJheSgpKSBpZiAoY2FyYWN0ZXJlID09IGxldHJhKSBjb250YWRvcisrOwogICAgICAgIGlmIChjb250YWRvciA9PSAwKSBTeXN0ZW0ub3V0LnByaW50bG4oIk5hbyBleGlzdGUgYSBsZXRyYSBuYSBmcmFzZSIpOwogICAgICAgIGVsc2UgU3lzdGVtLm91dC5wcmludGxuKCJBIGxldHJhIGFwYXJlY2UgIiArIGNvbnRhZG9yICsgIiB2ZXplcyIpOwogICAgfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8zMjgxMDQvMTAx