Java Arrays.sort(Object [] a, int fromIndex, int toIndex)
Syntax
Arrays.sort(Object [] a, int fromIndex, int toIndex) has the following syntax.
public static void sort(Object [] a, int fromIndex, int toIndex)
Example
In the following code shows how to use Arrays.sort(Object [] a, int fromIndex, int toIndex) method.
// ww w. j a va 2 s. c om
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// initializing unsorted Object array
Object ob[] = {27, 11, 5, 44,22,0};
System.out.println(Arrays.toString(ob));
// sorting array from index 1 to 3
Arrays.sort(ob, 1, 3);
System.out.println(Arrays.toString(ob));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »