Q:

try-catch when adding value to ArrayList is out of bound using loop Java

I'd like to add all values as 0.0 to an ArrayList which the size is set to be MAX=5. I am using a for loop to add the values. I would like to catch a out of bounds exception when the list is exceeding MAX size. A message would output the reason that the list size should be 5. Then it would print out the list values which would be 5 "0.0". 
I would test it by changing the MAX value to 8: 
try {   
for (int i=0; i<8; i++) 
myList.add(0.0);

I've tried putting the try{} inside the loop and add() after the while loop. The output would either be not catching the exception or doesn't return anything. The code I have below doesn't return anything. 
I must be asking the wrong questions because I can't seem to find the answer. Or that I am getting the logic completely wrong...I'd appreciate any guidance!
//This code doesn't return anything
import java.util.ArrayList; 
public class Values {
private static final int MAX = 5;
private ArrayList<Double> myList = new ArrayList<Double>(MAX); 

public Values()  {

try {   
for (int i=0; i< MAX; i++) {
    myList.add(0.0);
while ( i <0 || i > MAX) {}}    
}
catch (IndexOutOfBoundsException e) {
System.out.println(e.getMessage());
System.out.println("ArrayList size allowed at" + MAX);}

for (Double myList: myList) 
System.out.println(myList);
}

A:

1st: 
You are getting error because you have to declare i outside the for loop because the scope of i was within the for loop.
2nd:
By ArrayList<Double> myList = new ArrayList<Double>(MAX);  you are not fixing size of List. It's only setting it's initial capacity.
You need to something like below(in short):
int MAX = 5;

        ArrayList<Double> myList = new ArrayList<Double>(5);

        try {
            for (int i = 0; i < 8; i++)// to throw IndexOutOfBoundsException
            {
                if(myList.size()>MAX)
                    throw new IndexOutOfBoundsException("My message");
                myList.add(0.0);
            }
        } catch (IndexOutOfBoundsException e) {
            System.out.println("Exception : "+e.getMessage());

        }

N.B: Usage of IndexOutOfBoundsException is not required here. Showed just for your question.

