Arrays.sort(int[] a, int fromIndex, int toIndex) has the following syntax.
public static void sort(int[] a, int fromIndex, int toIndex)
In the following code shows how to use Arrays.sort(int[] a, int fromIndex, int toIndex) method.
//from w ww .j av a2 s.c om import java.util.Arrays; public class Main { public static void main(String[] args) { // initializing unsorted int array int iArr[] = {13, 11, 112, 18, 10}; System.out.println(Arrays.toString(iArr)); // sorting array from index 0 to 3 Arrays.sort(iArr, 0, 3); System.out.println(Arrays.toString(iArr)); } }
The code above generates the following result.