2D ArrayList

I am trying to creat a new ArrayList "list10CompWith00" after comparing the List "list10" only for those elements are greater than 5.0.  
and i am getting an error  
  
Comp List after adding  
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size: 1  
  
Please help me ...  
  
class Demo
{
List<List<Double>>list10 =new ArrayList<>();  
List<List<Double>>list10CompWith00 =new ArrayList<>();  
  
 public static void main(String[] args)
{
Demo obj =new Demo();  
obj.arrayToList();  
  
}
void arrayToList()
{
Double[][] arr10 = {{5.25, 4.12, 3.0, 6.0},  
{12.9, 2.09, 4.0, 7.0}};  
 for (Double[] ele : arr10)
{
list10.add(Arrays.asList(ele));  
}
System.out.println("Main List: ");  

for (List<Double> ele:list10)
{
System.out.println(ele);  
}
System.out.println();  
System.out.println("Comp List after adding");  
 for (int i=0; i<list10.size(); i++)
{
list10CompWith00.add(new ArrayList<>());  
 for (int j=0; j<4; j++)
{
if (list10.get(i).get(j)>5.0)
{
list10CompWith00.get(i).add(j, list10.get(i).get(j));  
}

}

}

for (List<Double> ele:list10CompWith00)
{
System.out.println(ele);  
}

}
  
}

Hi @phd-coder,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the Programming Help and Discussion board. No action is needed on your part; you can continue the conversation as normal here.

Cheers!

Your “for (int j=0; j<4;j++)” loop is making the assumption that each array inside list10[] has at least 4 elements. You should be limiting your loop to the size of the array inside list10[].