Well, this works, although there may be a more elegant solution.
Array is not a Collection, so you cannot use TreeSet's "addAll" or constructor to include elements. Sorry... you'll have to loop the good old-fashioned way, adding one element at a time.
Next, aSet must be declared to be of type SortedSet or TreeSet. Set won't work because you need to return a SortedSet
and SortedSet is a subclass of Set. So yeah, the following code should work...
public SortedSet arrayToSortedSet(Integer anArray)
SortedSet<Integer>aSet = new TreeSet<Integer>();
for(int i = 0; i < anArray.length; i++)
A perhaps more elegant solution is to find some type of collection that will allow you to convert arrays, and then use that collection with the treeset. Personally, I think this is alright.