How to initialize a single element to be true rather than initializing the whole array.
do {
if (flightClass == 1) {
Arrays.fill(seats, true);
} else if (flightClass == 2) {
Arrays.fill(seats, true);
}
} while (i <= 10);
My approach was to do this….
do {
if (flightClass == 1) {
int enterSeat = input.nextInt();
Arrays.fill(seats[enterSeat], true);
} else if (flightClass == 2) {
Arrays.fill(seats, true);
}
} while (i <= 10);
}
Instead of this:
Simply do this: