当前位置: 首页 > 知识库问答 >
问题:

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

王骏
2023-03-14

我在做一个井字游戏。这是代码的一部分,用于检查按下了哪个按钮,并查看该按钮中是否有圆圈或十字架。如果有一个圆圈或十字,那么玩家必须选择另一个按钮。

错误消息:

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个答案

陈斌
2023-03-14

有不止一个错误。首先,不能有两个返回语句!第二,你的圆圈和十字架看起来是字符串,但不是数组。toString()需要一个数组作为参数!请提供完整的代码。

 类似资料: