title: object is an instance of class (java)
body: <pre><code>System.out.print("Enter Room Number: ");
  int a4 = scan.nextInt();
  scan.nextLine();
  booking[count]= new RoomBooking (a1,a2,a3,a4);
  count++;
  
  if (/* if the object is an instance of RoomBooking(subclass) */) {
      for (int y = 0; y &lt; count; y++) {
          if (a4 == (((RoomBooking) booking[y]).getRoomNumber())) {
              System.out.print("Used number, Please Try again");
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>"if the object is an instance of RoomBooking(subclass)"
  How can i write that in java?</p>
  
  <p>Sorry if that doesn't make sense, still learning.</p>
  
  <p>If you need to know what's going on, there are 2 classes. 
  Booking (normal Booking) and RoomBooking ( which extends Booking)..
  Since we have to create one array which stores a mixture of both, i need to check if the object(a4) is an instance of the RoomBooking so i can compare the numbers.</p>
  
  <hr>
  
  <p>I have tried if ((RoomBooking.class.isInstance(a4))){...}
  but it didn't work.</p>