title: comparing values of two arrays if exist or not
body: <p>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? </p>
  
  <p>Thanks </p>
  
  <pre><code> 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&lt;x.length; i++)
              {
  
              for (int b=0;  b&lt;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&lt;x.length; i++)
              {
  
              for (int b=0;  b&lt;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");
                  }
  
              }
  
  
  
  
  
          }
  
  
      }
  </code></pre>