I have a List of Array values
String[] names = {"michel","john","mr x","text"};
int[] num ={1,2,3,4};
I asked the User to Enter the names in the array and want to dispaly the num of tht array names also we want to check whether the entered array is in the array if not then we want to send error msg
for that i created a boolean = false and check the condition in loop and i execute
System.out.println("Enter the Name To get Numbers");
Scanner scanner = new Scanner(System.in);
String name=scanner.next();
boolean check =false;
int in = 0;
for (int i=0; i <names.length; i++)
{
if (name.contains(names[i]))
{
check = true;
in = i;
}
if (name.equals(names[i]))
{
System.out.println(num[i]);
}else
{
System.out.println(" Choose the name in the array ");
}
}
But it execute the error in the loop till the no of array list