[英]Issue with cannot be converted to char[][] by method invocation conversion
This is my method that takes the total from the openCheckHorizontal,openCheckVertical, openCheckDiagonal methods which all return integers. 这是我的方法,该方法从所有都返回整数的openCheckHorizontal,openCheckVertical,openCheckDiagonal方法中获取总和。
public static void printRecord(char[][]data, int[][]record ){
int horizontal=0;
int vertical=0;
int diagonal=0;
int total=0;
for(int row=0; row<data.length;row++){
for(int col=0; col<data[row].length;col++){
***horizontal = openCheckHorizontal(data[row][col]);
***vertical=openCheckVertical(data[row][col]);
***diagonal=openCheckDiagonal(data[row][col]);
total = horizontal+vertical+diagonal;
record[row][col]=total;
}//end of second loop
}//end of first loop
for(int row =0; row<record.length; row++){
for(int col=0; col<record[row].length;col++){
System.out.print(record[row][col]);
}//end of second loop
System.out.println();
}//end of first loop
}//end of record method
The error I am getting is this: 我得到的错误是这样的:
actual argument char cannot be converted to char[ ][ ] by method invocation conversion for the lines marked with the stars. 实际的参数char不能通过方法调用转换为标有星号的行转换为char [] [] 。 I cannot figure out why this is. 我不知道为什么会这样。 I thought since the methods I invoked return integers I can store them as integers and call it back using my array. 我以为,由于我调用的方法返回整数,因此我可以将它们存储为整数,并使用我的数组将其回调。
The parameters that the three methods take are: char[ ][ ] myArray 这三种方法采用的参数是:char [] [] myArray
If anyone could help me out that would be great! 如果有人可以帮助我,那就太好了!
It looks like you may be passing the value of that array position which would be a char
. 看来您可能正在传递该数组位置的值,这将是一个char
。 Try changing the signatures on the three methods you are calling to take char
as a parameter. 尝试在要使用char
作为参数的三种调用方法上更改签名。 OR if you meant to pass in the whole array you should be able to just pass data
instead of the position data[row][col]
或者,如果您打算传递整个数组,则应该只传递data
而不是位置data[row][col]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.