Java Arrays.sort(double[] a)
Syntax
Arrays.sort(double[] a) has the following syntax.
public static void sort(double[] a)
Example
In the following code shows how to use Arrays.sort(double[] a) method.
/*from ww w . jav a 2 s.c o m*/
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// initializing unsorted double array
double dArr[] = {13.2, 1.2, 0.7, 6.2, 4.5};
System.out.println(Arrays.toString(dArr));
// sorting array
Arrays.sort(dArr);
System.out.println(Arrays.toString(dArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »