这是我应该将方法称为“ methodA”的部分:
for(GenNumber = 1; GenNumber < generations; GenNumber++)
{
for(cellNumber = 0; cellNumber < totalCount; cellNumber++)
{
row[cellNumber] = cells[cellNumber];
}
for(cellNumber = 1; cellNumber <= count; cellNumber++)
{
if(rule.equals(ruleA) == true)
{
row[cellNumber] = methodA(cellNumber, row); //here I try to call it
}
这是方法“ methodA”:
public static boolean methodA(int cellNumber, int row) {
int state = 0;
if(row[cellNumber-1] == true)
{
state++;
}
if(row[cellNumber+1] == true)
{
state++;
}
if(row[cellNumber] == true && state != 1)
{
return false;
}
else if(row[cellNumber] == false && state != 0)
{
return true;
}
}
问题是我不断收到10条错误消息:“需要数组,但找到int”。我显然做错了什么,甚至都不知道。请注意,我是编程新手,请不要太苛刻。 :)
最佳答案
row是int类型而不是数组...更改函数参数以采用int数组...
public static boolean methodA(int cellNumber, int[] row)