Java Check If Two Integer Arrays are Equals

Write a Java program that checks if the two given integer arrays are equals.
Check out Java 8 examples at Java 8 Examples
Checkout all Java programs at 50+ Java Programs 

Checking if two integer arrays are equals

package net.sourcecodeexamples.java;

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        // arrays of integers
        int[] integers1 = new int[] {
            3,
            4,
            5,
            6,
            1,
            5
        };
        int[] integers2 = new int[] {
            3,
            4,
            5,
            6,
            1,
            5
        };
        int[] integers3 = new int[] {
            3,
            4,
            5,
            6,
            1,
            3
        };

        System.out.println("equals:\n------\n");

        // integers1 equals integers2
        boolean i12 = Arrays.equals(integers1, integers2);
        System.out.println("integers 1 equal integers 2? " + i12);

        // integers1 equals integers3
        boolean i13 = Arrays.equals(integers1, integers3);
        System.out.println("integers 1 equal integers 3? " + i13);
    }
}

Output

equals:
------

integers 1 equal integers 2? true
integers 1 equal integers 3? false


Comments