Implementing quicksort with pivot of first, median or random I am attempting to implement the quick sort algorithm whereby the pivot will be chosen by the user, and can either be median, first, or random. I am supposed to return a long that measures the number of times comp.compare() is invoked. I am wondering if you could review for me.

/**
     * The quick sort 
     * @param arr the collection array
     * @param comp is the comparator
     * @param pivottype specifies where the pivot is going to be at, can either be "first", "middle", or "random"
     * @return returns the number of comparisons performed during the execution of the sorting algorithm
     */
    public static &lt;E&gt; long quickSort(E[] arr, Comparator&lt;? super E&gt; comp, String pivottype)
    {
        recursiveQuickSort(arr,0, arr.length -1,  pivottype, cp );
        return quickSortCounter;

    }
    private static&lt;E&gt; void recursiveQuickSort(E[] array, int first, int last, String pivottype, Comparator&lt;? super E&gt; comp)
    {
        if(first &lt; last)
        {
            int pivotPosition = partition(array, first, last, cp, pivottype);
            if(pivotPosition &gt; 1)
                recursiveQuickSort(array, first, pivotPosition-1, pivottype, cp);
            if(pivotPosition + 1 &lt; last)
                recursiveQuickSort(array, pivotPosition + 1, last, pivottype, cp);
        }

    }
    private static &lt;E&gt; int partition(E[] collectionArray, int firstIndex, int lastIndex, Comparator&lt;? super E&gt; comp, String pivottype)
    {
        int pivotLocation;
        // counts the number of times the cp.compare() is called
        quickSortCounter = 0;

        if(pivottype.equals("first"))
        {
            pivotLocation = firstIndex;
        }
        else if(pivottype.equals("middle"))
        {
            pivotLocation = (firstIndex + lastIndex)/2;
        }
        else
        {

            pivotLocation = rand.nextInt(lastIndex - firstIndex) + firstIndex;
        }

        E pivotElement = collectionArray[pivotLocation];

        while(firstIndex &lt;= lastIndex)
        {
            //scans right;
            while((firstIndex &lt;= lastIndex) &amp;&amp; (cp.compare(collectionArray[firstIndex], pivotElement) == -1))
            {
                firstIndex ++;
                quickSortCounter++;

            }
            //scans left
            while((lastIndex &gt;= firstIndex) &amp;&amp; (cp.compare(collectionArray[lastIndex], pivotElement) == 1) ||
                    (lastIndex &gt;= firstIndex) &amp;&amp; (cp.compare(collectionArray[lastIndex], pivotElement) == 0))
            {
                lastIndex--;
                quickSortCounter++;
            }
            if(firstIndex &gt;  lastIndex)
            {
                swap(collectionArray, pivotLocation, lastIndex);
            }
            else
            {
                swap(collectionArray, firstIndex, lastIndex);
            }

        }
        return lastIndex;

    }
    private static &lt;E&gt; void swap(E[] array, int i, int j)
    {
        E temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }

}
quickSortCounter is reset too often
If the goal of the program is to count compares, the counter you are using is being reset in the wrong place.  Right now, you are going to end up with only the number of compares in the last call to partition(), which will likely be close to 0.  You need to move the quickSortCounter = 0 line to right before you call recursiveQuickSort().  That way you will add up all the compares in the entire sort.
You can also do it a different way without using a static variable.  You just need to have partition() be able to return the count to its caller.  One way of doing this would be to have partition() return an int [2] (one int for the partition index and the other int for the number of compares).  Another way is to pass an int [1] or Integer variable into partition() and write the compare count into that variable before returning.
Naming
One thing confused me about your variable names.  You used array as you array everywhere, but then you called it collectionArray in partition().  Why &quot;collection&quot;?