Sort int Array in Java
Description
The following code shows how to sort int Array.
Example
//w w w. j a v a 2 s .c o m
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] i1 = new int[] { 2, 2, 5, 4, 1 };
for (int i:i1){
System.out.print(" " + i);
}
Arrays.sort(i1);
for (int i:i1){
System.out.print(" " + i);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »