// test for rock
List rocks = getWorld().getObjectsAt(x , y, Rock.class);
/* Look up the List class (java.util.List) in the Java API
* and determine what method to use with the 'rocks' List
* to determine if there was a rock. Put the correct test
* in the 'if()' statement below.
*/
if () {
return true;
}
return false;
必须填写上面的“if()”语句返回true; 真的很困惑如何用lst获取if语句。 请帮忙!并发送如何做的知识!非常感谢你们!
答案 0 :(得分:0)
如果我理解正确,你想要的是检查一个具体的物体Rock是否在列表'rock'上。然后你只需要使用方法“包含”。 public boolean List.contains(Object o)检查列表中是否存在对象“o”。
Rock myRock = //whatever sentence you use to create the rock you're checking
if (rocks.contains(myRock) {
return true;
}
return false;
答案 1 :(得分:0)
怎么样:
if (!rocks.isEmpty()) { //is true if your list with rocks is not empty
return true;
}