Sort a subset of array elements in Java
Description
The following code shows how to sort a subset of array elements.
Example
/*from w w w. ja v a 2 s.c om*/
import java.util.Arrays;
public class Main {
public static void main(String[] a) {
int array[] = { 2, 5, -2, 6, -3, 8, 0, -7, -9, 4 };
Arrays.sort(array, 3, 7);
for (int i : array) {
System.out.println(i);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »