Print all possible combinations of size r, from an array of size n
I think that by avoiding duplicates, you are essentially changing the definition of the question at hand.

If that is indeed the definition of question, then instead of sorting the array and avoiding duplicates, you can simply get rid of the duplicates to begin with by using a set instead of an array:

Set&lt;Integer&gt; set = new HashSet&lt;Integer&gt;();
for (int i : arr)
    set.add(i);




In addition, for better modularity, I think that you should separate the algorithm itself from the printing:


Create an empty List&lt;List&lt;Integer&gt;&gt; instance
Pass it to the doCombine method, to fill it in with all combinations
Print it in the main method (the combine method looks kind of redundant)