当试图比较作为参数传递的两个对象时:第一个作为对象,第二个作为对象数组(相同类型)。得到错误Incompatible conditional operand types Room and allRooms[]
。我正在尝试循环迭代,while
直到thisRoomType
不等于来自rooms
. 如何解决?
public abstract class Room { ...}
public class LightRoom extends Room {...}
public class DarkRoom extends Room {...}
呼叫者:
release(thisRoomType, rooms)
带参数
private Room thisRoomType = this; // is defined in DarkRoom and LightRoom
private Room[] rooms; // is defined in DarkRoom and LightRoom
在方法中:
public synchronized void release( Room thisRoom, Room[] allRooms) {
try {
int j = 0;
while(thisRoom instanceof allRooms[j]){
jj++;
}
int nextRoom = jj;
...
}
}