compare int Array Value - Java java.lang

Java examples for java.lang:int Array

Description

compare int Array Value

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int[] a = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        int[] b = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(compareArrayValue(a, b));
    }//ww  w.  j  a  v  a2s . c o m

    public static boolean compareArrayValue(int[] a, int[] b) {
        if ((a.length == b.length) && (a.length != 0)) {
            for (int i = 0; i < a.length; i++) {
                boolean flag = false;
                for (int j = 0; j < b.length; j++) {
                    if (a[i] == b[j])
                        flag = true;
                }
                if (flag == false)
                    return false;
            }
            return true;
        } else
            return false;
    }
}

Related Tutorials