Hi guys I am currently learning Java and I'm trying to make a program that you can use too book motel rooms. I'm trying to create a method to search the amount of days a guest needs and then check the days and units that are free. I'm using a 2D array of an array of an array.
public void doSearch() {
this.redisplay();
int daysWanted = UI.askInt("Number of days required");
int days = 0;
for(int i = 0; i < NUM_UNITS; i++){
for(int j = 0; j < NUM_DAYS; j++){
if(bookings[i][j] == null){
days++;
if(daysWanted >= days && this.bookings[i] == this.bookings[i]){
this.displayCell (i, j, Color.red);
}
}
}
}
}

here is what the program looks like currently, and what i have shown above is the method i am trying to do. What my problem is, when i type in how many days, it checks if the available unit is free for that many days, but i want it to be consequtive. How would i go about this? any help is appreciated, thanks :)
if(daysWanted >= days && this.bookings[i] == this.bookings[i]){this line is incorrect because the second condition is always true.