Number of distinct elements in an array
Your code was better in Rev 1.  I don't know why you changed it.  Whenever you can get away without special cases, it's probably better to do so.

This code is a pure function of the input array and nothing else.  Therefore, it would probably be better as a static function.

Renaming the function from NumberOf… to …Count would make it less verbose.  You should also respect Java naming conventions, in which method names start with a lowercase letter.  The parameter name A also has unconventional capitalization.

As others have said, your algorithm, using TreeSet, is O(n log n).  You would need a HashSet for O(n).  When constructing a HashSet, it's a good idea to provide an estimate of the collection size, since a wrong guess would hurt performance.

public static int distinctItemCount(int[] array) {
    Set&lt;Integer&gt; set = new HashSet&lt;Integer&gt;(array.length);
    for (int i : array) {
        set.add(i);
    }
    return set.size();
}