Вопрос

My goal is to convert this Arrays.sort(nums, j+1, nums.length) into a reverse sort. The only reverse sort information I can find doesn't seem to have the ability to sort a subarray.

And this gives me an error Arrays.sort(nums, j+1, nums.length, Collections.reverseOrder());

Это было полезно?

Решение

Since the Collections.reverseOrder() method only works for reference type, my suggestion is that your "nums" should hold reference type such as Integer, Double ... Or if you defined your own class, make sure your class implemented the Comparable interface

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top