I'm trying to make a login type validation, In the long run, I need to tokenize items from a .txt file, but for now, I just have the items inside of an array.
I'm trying to validate if the item is contained within the array(and what is the index of that item)
package pkgMTA;
import java.io.*;
import java.util.Scanner;
import java.util.*;
public class pkgMTA {
public static void main(String[] Args) throws IOException {
Scanner scan = new Scanner(System.in);
boolean validations = false;
String[] gArray = new String[5];
gArray[0] = "AAA";
gArray[1] = "BBB";
gArray[2] = "CCC";
gArray[3] = "DDD";
gArray[4] = "EEE";
String input;
input = scan.nextLine();
for( int i = 0; i < gArray.length; i++)
{
if( gArray[i].equals(input)){
validations = true;
}
else{
validations = false;
}
}
if (validations){
System.out.println("nice");
}
else {
System.out.println("error");
}
}
}