My goal is to get the alphabet letter that the user typed in and show, how many times he typed, the letters that preceded him and his successors, do you understand? Here's what I did:
static int v;
static String[] Alfa = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
public static void main(String[] args) {
String letra;
Scanner s = new Scanner(System.in);
System.out.print("Digite uma letra: ");
letra = s.nextLine();
System.out.print("Quantas letras deseja mostrar?");
v = s.nextInt();
for(int i = 1; i < Alfa.length; i++) {
if(letra == Alfa[i]) {
for(int i; i <= 1;) {
System.out.print(Alfa[i--] + " ");
}
System.out.print(Alfa[i]);
for(int i; i <= v;) {
System.out.print(" " + Alfa[i++]);
}
}
}
}
It turns out that I have to use the value of Alpha [i] that is inside the if for's, but how do I do that?