错误:没有为toString(String)找到合适的方法

时间:2017-02-19 21:42:19

标签: java android arrays string android-studio

我正在制作一个tic tac toe游戏。这是代码的一部分,它检查按下了哪个按钮,并查看该按钮中是否有圆圈或十字形。如果有一个圆圈或十字架,那么玩家必须选择另一个按钮。

错误消息:

Error:(140, 38) error: no suitable method found for toString(String)
method Arrays.toString(long[]) is not applicable
(argument mismatch; String cannot be converted to long[])
method Arrays.toString(int[]) is not applicable
(argument mismatch; String cannot be converted to int[])
method Arrays.toString(short[]) is not applicable
(argument mismatch; String cannot be converted to short[])
method Arrays.toString(char[]) is not applicable
(argument mismatch; String cannot be converted to char[])
method Arrays.toString(byte[]) is not applicable
(argument mismatch; String cannot be converted to byte[])
method Arrays.toString(boolean[]) is not applicable
(argument mismatch; String cannot be converted to boolean[])
method Arrays.toString(float[]) is not applicable
(argument mismatch; String cannot be converted to float[])
method Arrays.toString(double[]) is not applicable
(argument mismatch; String cannot be converted to double[])
method Arrays.toString(Object[]) is not applicable
(argument mismatch; String cannot be converted to Object[])

我收到了这个错误,但不知道什么是错的。

代码:

                @Override
                public String toString() {
                    return Arrays.toString(Circle);
                    return Arrays.toString(Cross);
                }

1 个答案:

答案 0 :(得分:0)

有多个错误。 首先,没有两个返回语句! 其次,你的Circle和Cross似乎是字符串,但是Arrays.toString()需要一个数组作为参数! 请提供完整的代码。