Java Case 6: determine whether two arrays are equal

1. Analyzing two arrays are equal

    / *
     * Need to design a method, it is determined whether the same two arrays
     * ideas: 1, define two arrays, each assigned static initialization
     * 2. The comparison of the two arrays define a method
     * Return Value: Boolean
     * Parameters: int [ ] ARR, int [] arr2 is
     * 3. first length comparison of different lengths directly back to false
     * Second traversal, traverse exactly equal, it returns true, otherwise to false
     * /
    
    public static Boolean judgeArray (int [] ARR, int [] arr2 is) {
        IF (arr.length == arr2.length) {
            for (int I = 0; I <arr.length; I ++) {
                IF (ARR [I] == arr2 is [I]) {
                    ;
                } the else {
                    return to false;
                }
            }
        } the else {
            return to false;
        }
        return to true;
    }

Guess you like

Origin www.cnblogs.com/wazl/p/11528135.html