public class Maxx { public static void main(String[] args) { // step one create array and fill it double[] dArray = new double[10]; for (int i = 0; i < dArray.length; i++) { dArray[i] = Math.random(); } // Now get the max double maxx = 0.0; // this is a bad way to start for (int i = 0; i < dArray.length; i++) { if (maxx < dArray[i]) { maxx = dArray[i]; } } // Finally print the array and the max for (int i = 0; i < dArray.length; i++) { System.out.println(i + " " + dArray[i]); } System.out.println("The max of the above is " + maxx); } }