How to fix 'The method mismatch(int[], int[]) is undefined for the type Arrays'

Fabian Schwarz :

I'm currently learning about Array methods, but struggling with the mismatch(...)-method. The compiler always throws me the unresolved compilation problem: The method mismatch(int[], int[]) is undefined for the type Arrays, although both of the passed arguments are of the type int[]

import java.util.Arrays;

public class Test {

    public static void main(String... args) {


        int[] a = {1, 2, 3};
        int[] b = {1, 2, 3};

        System.out.println(Arrays.mismatch(a, b));

    }

}

I expect the printed output to be -1, but I get the described error.

Gabriele Mariotti :

The method mismatch(int[], int[]) is undefined for the type Arrays

You can check the doc.
This method requires java 9.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=154206&siteId=1