我在谷歌搜索但没有找到任何修复程序......以下是代码:
public Command getCommandbyAlias(String alias)
{
int length;
int i;
for (Iterator localIterator = getCommands().iterator(); localIterator.hasNext(); i < length) //Here, at i < length
{
Command cmd = (Command)localIterator.next();
String[] alias2;
length = (alias2 = cmd.getAlias()).length;
i = 0;
continue;
String aliases = alias2[i];
Utils.addChatMessage(aliases);
if (aliases.equalsIgnoreCase(alias)) {
return cmd;
}
i++;
}
return null;
}
答案 0 :(得分:1)
for循环中的第三个参数不正确。我猜你想要这样的东西:
for (Iterator localIterator = getCommands().iterator(); localIterator.hasNext() && i < length; )
答案 1 :(得分:1)
根据oracle doc s
class A(object):
def __init__(self, y):
self.x = 2
self.y = y
class B(A):
def __init__(self, y, z):
super().__init__(y) # equivalent to: A.__init__(self, y)
self.z = z
b = B(3, 4)
# b's x is 2, b's y is 3 (both set by A.__init__, the last one was passed by B), and b's z is 4 (set by B.__init__)
第三个论点是为增量/减量语句保留的,它是可选的
如果您对使用for循环感到困惑,请按以下代码
转到for (initialization; termination;
increment) {
statement(s)
}
while
答案 2 :(得分:0)
如果在for
语句中需要两个条件,则应使用&&
布尔运算符将它们连接到单个条件:
for (Iterator localIterator = getCommands().iterator();
localIterator.hasNext() && i < length) {
顺便说一句,请注意,在尝试使用它们之前,应初始化i
和length
。你当前的代码没有。
答案 3 :(得分:0)
试试这个:
public Command getCommandbyAlias(String alias)
{
int length;
int i;
Iterator localIterator = getCommands().iterator();
while (localIterator.hasNext() && i < length)
{
Command cmd = (Command)localIterator.next();
String[] alias2;
length = (alias2 = cmd.getAlias()).length;
i = 0;
continue;
String aliases = alias2[i];
Utils.addChatMessage(aliases);
if (aliases.equalsIgnoreCase(alias)) {
return cmd;
}
i++;
}
return null;
}