Find the 2 distinct highest values in an array
Here's a simple implementation which will return the max (first index in return array) and second distinct max (second index in return array) value as an array.  If the list is size zero or there is no distinct max value, then Integer.MIN_VALUE is returned.

/**
 * @param integer array
 * @return an array comprising the highest distinct value (index 0) and second highest distinct
 *         value (index 1), or Integer.MIN_VALUE if there is no value.
 */
public int[] findTwoHighestDistinctValues(int[] array)
{
    int max = Integer.MIN_VALUE;
    int secondMax = Integer.MIN_VALUE;

    for (int value:array)
    {
        if (value &gt; max)
        {
            secondMax = max;
            max = value;
        }
        else if (value &gt; secondMax &amp;&amp; value &lt; max)
        {
            secondMax = value;
        }
    }
    return new int[] { max, secondMax };
}