[英]I'm getting this error message and understand why: cannot be applied to given types; required: no augments found: int, int
This may be a lack of sleep situation but I cannot figure out why I'm getting this message, I know it'll be a simple fix but I cannot wrap my head around it, any help is appreciated.这可能是缺乏睡眠的情况,但我无法弄清楚为什么我会收到此消息,我知道这将是一个简单的修复,但我无法解决它,感谢任何帮助。
For context, I'm trying to take the user's input and then plug that in and compare that to the values in a 2D array.对于上下文,我正在尝试获取用户的输入,然后将其插入并将其与 2D 数组中的值进行比较。
This is the array I'm trying to compare这是我要比较的数组
String[][] board = {{"-", "-", "-", "-", "-", "-", "-", "-"},
{"-", "-", "-", "-", "-", "-", "-", "-"},{"-", "-", "-", "-", "-", "-", "-", "-"},
{"-", "-", "-", "-", "-", "-", "-", "-"},{"-", "-", "-", "-", "-", "-", "-", "-"},
{"-", "-", "-", "-", "-", "-", "-", "-"},{"-", "-", "-", "-", "-", "-", "-", "-"},
{"-", "-", "-", "-", "-", "-", "-", "-"}};
public void makeMove() {
Scanner choice = new Scanner(System.in);
System.out.println("Enter the row");
int tempCol = choice.nextInt();
System.out.println("Now the column");
int tempRow = choice.nextInt();
// a.setPiece(tempRow, tempCol, "W");
a.isValid(tempRow, tempCol);
}
a.isValid is throwing out the error message: a.isValid 正在抛出错误消息:
method isValid in class board cannot be applied to given types;
required: no arguments
found: int, int
reason: actual and formal argument lists differ in length
And this is the method I'm trying to communicate with:这是我试图与之交流的方法:
public void isValid() {
if (board[tempRow][tempCol] = "W") {
display();
} else {
System.out.println("Move invalid, try again");
makeMove();
}
}
This also throws out a different error message but I'm going to create a new question for that这也会抛出不同的错误消息,但我将为此创建一个新问题
isValid() does not have any parameters declared, but your are passing two ints. isValid() 没有声明任何参数,但是您传递了两个整数。 Did you mean to declare it like this?
你的意思是这样声明吗?
public void isValid(int tempRow, int tempCol){
if(board[tempRow][tempCol] = "W"){
display();
} else {
System.out.println("Move invalid, try again");
makeMove();
}
}
Your isValid
method doesn't take any arguments, but you try to pass it 2 int
s anyways.您的
isValid
方法不需要任何 arguments,但无论如何您都尝试将其传递 2 int
。 You'll have to change your declaration to say:你必须改变你的声明说:
public void isValid(int tempRow, int tempCol){
That way it can actually take your int
s and process them.这样,它实际上可以获取您的
int
并处理它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.