title: Cannot compare two objects using instanceof
body: <p>When trying to compare two objects passed as arguments: first as object, second as array of objects (the same kind). Getting error <code>Incompatible conditional operand types Room and allRooms[]</code>. I am trying to iterate in <code>while</code> cycle until <code>thisRoomType</code> is not equals to some object from <code>rooms</code>. How to fix it?</p>
  
  <pre><code>public abstract class Room { ...}
  public class LightRoom extends Room  {...}
  public class DarkRoom extends Room {...}
  </code></pre>
  
  <p>Caller:</p>
  
  <pre><code>release(thisRoomType, rooms)
  </code></pre>
  
  <p>with parameters </p>
  
  <pre><code>private Room thisRoomType = this; // is defined in DarkRoom and LightRoom 
  private Room[] rooms; // is defined in DarkRoom and LightRoom 
  </code></pre>
  
  <p>in method:</p>
  
  <pre><code>public synchronized void release( Room thisRoom,  Room[] allRooms) {
  
          try {
              int j = 0;
              while(thisRoom instanceof allRooms[j]){     
                  jj++;
              }
                          int nextRoom = jj;
  ...
      }
  }
  </code></pre>