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