title: Check if array elements are filled in java
body: <p>I'm working on a simple reservation system with 10 elements (seats). I want to check if elements from 1 to 5 has been set. If Yes, then set the elements from 6 to 10 (Vice-Versa).</p>
  
  <p>An element should not be assigned a value more than once. My code so far.</p>
  
  <pre><code>    boolean[] seats = new boolean[10];
  
      Scanner input = new Scanner(System.in);
      System.out.print("Choose FirstClass(1) / Economy(2): ");
      int flightClass = input.nextInt();
  
      for (int j = 0; j &lt; seats.length; j++) {
          System.out.println("\nEnter Seat Number: ");
          int enterSeat = input.nextInt();
          if (flightClass == 1) {
              if (enterSeat &gt;= 0 &amp;&amp; enterSeat &lt;= 5) {
                  System.out.println("You're in the First Class.");
  
                  seats[enterSeat] = true;
                  System.out.printf("You're Seat Number is %d\n", enterSeat);
  
              }
  
          } else if (flightClass == 2) {
              if (enterSeat &gt;= 6 &amp;&amp; enterSeat &lt;= 10) {
                  System.out.println("You're in the Economy.");
  
                  seats[enterSeat] = true;
                  System.out.printf("You're Seat Number is %d\n", enterSeat);
              }
  
          }
  </code></pre>
  
  <p>My Question: How do I check if elements from 1 to 5 has been set, and if they have, set the elements from 6 to 10, and vice versa? </p>
  
  <p>For example:</p>
  
  <p>Enter seat no. to book:
  1</p>
  
  <p>Enter seat no. to book:
  2</p>
  
  <p>Enter seat no. to book:
  3</p>
  
  <p>Enter seat no. to book:
  4</p>
  
  <p>Enter seat no. to book:
  5 </p>
  
  <p>All the first class seats(1-5) has been set. Now the remaining seats are from 6 - 10.</p>
  
  <p>Enter seat no. to book:
  6 so on... </p>