title: Comparing two String arrays
body: <p>I'm making a program that compares two text files and returns their similarity (based on a given algorithm). For each unique word in the first file, I want to find the probabilities that they occur in the second file. But whenever I run my program the similarity returned is always 0.0. This is what I have right now:</p>
  
  <pre><code>public static double nestedLoop(String[] doc1, String[] doc2) {
      // nested loop: sort doc1, for each unique word in doc1, find all
      // occurences in doc2 using a sequential search
  
      java.util.Arrays.sort(doc1);
  
      double similarity = 0.0;
  
      for (int i = 0; i &lt; doc1.length - 1; i++) {
          if (doc1[i] != doc1[i + 1]) {
          String unique = doc1[i];
          double count = 0.0;
              for (int j = 0; j &lt; doc2.length; j++) {
                  if (unique == doc2[j]) {
                      count++;
                      similarity += count / doc2.length;
                  }
              }
          }
      }
      return similarity;
  }
  </code></pre>
  
  <p>Can someone tell me what is going on?</p>