Question: I have this code which is to check in the two arrays and print out the values that dont exist in the other array. I think the way i did it is not the most efficient way to do it hence can anyone offer a better OOP way to write this code in Java? 

Thanks 

```
 public class Calculate {
        static int [] x = {1,2,4,6,7};
        static int [] y = {2,3,4,6,7}; 
        static boolean xflag = true;
        static boolean yflag = true;

        public static void main(String[] args) {
            // TODO Auto-generated method stub

            for(int i = 0; i<x.length; i++)
            {

            for (int b=0;  b<y.length; b++)
                {
                    if(x[i]!= y[b])
                    {
                        xflag= false;

                    }
                    else
                    {
                        xflag = true;
                        break;
                    }

                }

                if(xflag==false)
                {
                    System.out.println(x[i] +" does not exist in array 2");
                }

            }

            for(int i = 0; i<x.length; i++)
            {

            for (int b=0;  b<y.length; b++)
                {
                    if(y[i]!= x[b])
                    {
                        yflag= false;

                    }
                    else
                    {
                        yflag = true;
                        break;
                    }

                }

                if(yflag==false)
                {
                    System.out.println(y[i] +" does not exist in array1");
                }

            }

        }

    }

```

Answer: 
Using Collection class removeAll method

```
  String original[] = { "1","2","3","4","6"};
     String testStr[] = { "1","2","3","5","7" };
        List origList = new ArrayList(Arrays.asList(original));
        List testList = new ArrayList(Arrays.asList(testStr));

        System.out.println(origList.removeAll(testList));
        System.out.println(origList);

```
You may use Apache's `CollectionUtils` for this purpose if you want an abstraction from the implementation logic.E.g:

```
public static void main(String[] args) {
        List<Integer> list1=Arrays.asList(1,2,4,6,7);
        List<Integer> list2=Arrays.asList(2,3,4,6,7);

    System.out.println(CollectionUtils.disjunction(list1,list2));
    }

```