문제

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