title: Alternative to Nested Loop For Comparison
body: <p>I'm currently writing a program that needs to compare each file in an ArrayList of variable size.  Right now, the way I'm doing this is through a nested code loop:</p>
  
  <pre><code>         if(tempList.size()&gt;1){
              for(int i=0;i&lt;=tempList.size()-1;i++)
                  //Nested loops.  I should feel dirty?
                  for(int j=i+1;j&lt;=tempList.size()-1;j++){
                      //*Gets sorted.
                      System.out.println(checkBytes(tempList.get(i), tempList.get(j)));
                  }
              }
  </code></pre>
  
  <p>I've read a few differing opinions on the necessity of nested loops, and I was wondering if anyone had a more efficient alternative.</p>
  
  <p>At a glance, each comparison is going to need to be done, either way, so the performance should be fairly steady, but I'm moderately convinced there's a cleaner way to do this.  Any pointers?</p>
  
  <p>EDIT::  This is only a part of the function, for clarity.  The files have been compared and put into buckets based on length - after going through the map of the set, and finding a bucket which is greater than one in length, it runs this.  So - these are all files of the same size.  I will be doing a checksum comparison before I get to bytes as well, but right now I'm just trying to clean up the loop.</p>
  
  <p>Also, holy cow this site responds fast.  Thanks, guys.</p>
  
  <p>EDIT2::  Sorry, for further clarification: The file handling part I've got a decent grasp on, I think - first, I compare and sort by length, then by checksum, then by bytes - the issue I have is how to properly deal with needing to compare all files in the ArrayList efficiently, assuming they all need to be compared.  If a nested loop is sufficient for this, that's cool, I just wanted to check that this was a suitable method, convention-wise.</p>