We would like to know how to sort a subset of array elements.
import java.util.Arrays; public class MainClass { public static void main(String[] a) { int array[] = { 2, 5, -2, 6, -3, 8, 0, -7, -9, 4 }; Arrays.sort(array, 3, 7);/*from w w w . j a v a 2 s. c o m*/ for (int i : array) { System.out.println(i); } } }
The code above generates the following result.