Java examples for Language Basics:Array
Sort double Array into ascending order
import java.util.Arrays; public class Main { public static void main(String[] args) {/*w w w .j a v a2s . c o m*/ // sort doubleArray into ascending order double[] doubleArray = {8.4, 9.3, 0.2, 7.9, 3.4}; Arrays.sort(doubleArray); System.out.printf("%ndoubleArray: "); for (double value : doubleArray) System.out.printf("%.1f ", value); } // output values in each array public static void displayArray(int[] array, String description) { System.out.printf("%n%s: ", description); for (int value : array) System.out.printf("%d ", value); } }