-1
A good practice in Stackoverflow is to send code using the site’s own text editor (as in the code below), not in image! About your question:
class Main {
public static void main(String[] args) {
String palavra = "abacate";
char buscar = 'c';
int indice = -1;
for(int i=0;i<palavra.length();i++) {
char atual = palavra.charAt(i);
if(atual == buscar) indice = i;
}
if(indice != -1) System.out.println("Indice: "+indice);
else System.out.println("Char nao encontrado!");
}
}
I adapted my program with your tips and I got it now, and I will also follow your tip on how to send the code, thank you so much for both!
– Daniel Manhães