title: Number of Comparisons in Bubble Sort
body: <p>I am trying to make a method for comparisons in my bubble sort class. However, I keep getting the same value. Is there any way to fix this? Thanks.</p>
  
  <pre><code>public void comparisons(int[] array)
  {
  int count = 0;
  for (int i = 0; i &lt; array.length - 1; i++)
  {
   for (int j = 0; j &lt; array.length - i - 1; j++)
   {
     count++;
     if ((array[i] &gt; array[i + 1])) //Swaps the elements
     {
       int temp = array[i]; 
       array[i] = array[i + 1];
       array[i + 1] = temp;
     }
   } 
  }
  System.out.print("\n\nComparisons:" + count);
  }
  </code></pre>