title: Java: How to compare every two elements in an array once?
body: <p>This is an assignment we have and I'm a little bit lost with his directions. He tells us to write a program with a method called equals to compare the salary of EVERY TWO EMPLOYEES in the array (I've already created this) and prints the SSN of every two employees that have the same salary in pairs. He made a disclaimer that
  the code should only compare two different employees and only once. Every two different employees are compared only once. The array is size 10. </p>
  
  <p>I've already asked multiple peers on what he meant but they are also confused. This is what I have:
  For the Class:</p>
  
  <pre><code>    public boolean equals(Employee e)
      {
          boolean status;
          if(salary == e.getSalary())
          {
             status = true;
          }
          else
             status = false;
          return status;
      }
  </code></pre>
  
  <p>For the Demo:</p>
  
  <pre><code>     for(int i = 0; i &lt; employees.length; i++)
       {
          for(int j = i+1; j &lt; employees.length; j++)
          {
             if(employees[i].equals(employees[j]))
                System.out.println(employees[i].getSsn() + "\t" + 
                                   employees[j].getSsn());
          }
       }
  </code></pre>
  
  <p>It compiles, however it skips comparing index 0 and index 1. Any help is appreciated. </p>