Java Arrays.sort(int[] a)
Syntax
Arrays.sort(int[] a) has the following syntax.
public static void sort(int[] a)
Example
In the following code shows how to use Arrays.sort(int[] a) method.
//from www.ja v a2 s .c om
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// initializing unsorted int array
int iArr[] = {12, 1, 119, 16, 4};
System.out.println(Arrays.toString(iArr));
// sorting array
Arrays.sort(iArr);
System.out.println(Arrays.toString(iArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »