Pregunta

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());

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top