Q:

Error finding largest randomly generated double in ArrayList Java

I'm trying to get a program to work where I generate 1,000,000 random numbers between 0 and 1 and then find and print the largest number.
I've got the generator to work and managed to insert each double generated into an ArrayList but I cannot seem to figure out how to find the largest number in the list. At the moment the current code throws the error "java.lang.IndexOutOfBoundsException".
This is all probably due to me being new to the ArrayList and not being fluent with its commands and how it works but I would really appreciate some help on what I'm doing wrong here as I've been stuck for a  while.
import java.util.ArrayList;
import java.util.Random;
public class milran {
    public static void main(String[] args) {
        Random r = new Random();
        ArrayList<Double> myList = new ArrayList<Double>();
        for (int i = 1; i<=1000000; i++){
            double randomValue = 0.0+(1.0-0.0)*r.nextDouble();
            myList.add(randomValue);

        }
        double max = myList.get(1);
        for (int z=2; z<=myList.size(); z++){
            double test = myList.get(z);
            if (test>max){
                max = test;
            }
        }
        System.out.println(max);
    }
}

A:

First of all take a look at the docs for java.util.Collections and java.util.ArrayList.
Secondly, the ArrayIndexOutOfBoundsException is being triggered by this...
for (int z=2; z<=myList.size(); z++){
        double test = myList.get(z);
        ...
}

This is because array indexing starts at 0, therefore the last element is myList.size() - 1. In other words, when z = myList.size(), it is out of bounds. 
Also, in your first for loop, you are using i = 1; 1 <= 1000000. It makes much more sense to use i = 0; i < 1000000 as you can use i to touch each element in an array (or list).
for( i = 0; i < 1000000; i++ )
{
    // do something with myArray[i]
} 

Here's what I would do after the values have been inserted...

Sort the array: Collections.sort(myList);
Retrieve the last element: System.out.println( myList.get( myList.size() - 1 ) );

...and that's it.
If you need to implement the actual sort yourself then i'd consider using a primitive double array (double[]) rather than a Collection. 
Otherwise, if you are using a collection, you can use a foreach loop.
for( Double d : myList ) // for each Double 'd' in myList
{
    // do something with d
}

N.B. Another potential issue with this line in the second loop
double test = myList.get(z);

This automatic conversion from Double (object) to double (primitive) is called unboxing. There will be a performance cost, especially when repeated a million times. In the first loop you are converting the other way (autoboxing) – also a million times.

