数组比较 - 参数列表

时间:2017-05-04 17:07:45

标签: java

我正在尝试获取两个数组的用户输入并进行比较,以下是我在获取数组大小的用户输入后的代码片段:

        String[] words = new String[size];

        for (i = 0; i < words.length; i++){
            System.out.print("Insert a word: ");
            words[i] = input.next();
        }

        String[] words2 = new String[size2];

        for (j = 0; j < words2.length; j++){
            System.out.print("Insert a word: ");
            words2[j] = input.next();
        }

        boolean result= Arrays.equals(words, words2);
        System.out.print("Arrays are equal: " + result);
        }
    }

我一直在寻找其他问题来解决这个错误,但我没有成功。

Method equals in class Object cannot be applied to given types;
 boolean result= Arrays.equals(words, words2);
  required: Object
  found: String[],String[]
  reason: actual and formal argument lists differ in length

0 个答案:

没有答案