Sort double Array in Java
Description
The following code shows how to sort double Array.
Example
//from w w w. ja v a 2 s.c om
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
double[] d1 = new double[] { 3.1, 2.1, 5.1, 4.1, 1.1 };
System.out.print(Arrays.toString(d1));
Arrays.sort(d1);
System.out.print(Arrays.toString(d1));
double[] d2 = new double[] { 5, 2, 3, 1, 4 };
Arrays.sort(d2, 1, 4);
System.out.print(Arrays.toString(d2));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »