I write 2 ArrayList type String contains the days and possible times , and I want the user to enter input , then check if the input is not from the array it will show a message that the input is invalid and the user enter again . but the result to my code give me the opposite :( when I enter something outside the array it will accept it 
what's wrong with my code?? 
and please show me the right code :(
package javaapplication19;
import java.util.ArrayList;
import java.util.Scanner;
public class JavaApplication19 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        ArrayList<String> dayArray = new ArrayList<>();
        ArrayList<String> timeArray = new ArrayList<>();
        dayArray.add("sunday");
        dayArray.add("monday");
        dayArray.add("tuesday");
        dayArray.add("wednesday");
        dayArray.add("thursday");
        timeArray.add("8am");
        timeArray.add("9am");
        timeArray.add("10am");
        timeArray.add("11am");
        timeArray.add("12pm");
        timeArray.add("1pm");
        timeArray.add("2pm");
        timeArray.add("3pm");
        timeArray.add("4pm");
        System.out.println("please enter day :");
        String a1 = input.nextLine();
        for (int g = 0; g < dayArray.size(); g++){
            if (dayArray.get(g).equals(a1))
                System.out.println("invalid day , please enter another day : ");
        a1 = input.nextLine();
}
        System.out.println("please enter time : ");
        String a2 = input.nextLine();
        for (int s = 0; s < timeArray.size(); s++) {
            if (timeArray.get(s).equals(a2))
                System.out.println("invalid time , please enter another time : ");
            a2 = input.nextLine();
        }
    }
}
 
     
     
     
     
    