I have following code
List<double[]> alParent = new ArrayList<>();
alParent.add(new double[]{15.22,25.22});
alParent.add(new double[]{1.1,2.3});
double tempone[] = {1,2};
double temptwo[] = {4,5};
alParent.add(tempone);
alParent.add(temptwo);
I have stored array of type double[] inside arraylist.
I want to access elements from arraylist which are on first position and second position double[] array. For my example I want to access 15.22,1.1,1,4 and 25.22,2.3,2,5 separately. Is there any way i can get specific elements stored inside arraylist?
Also, if i have more elements in arraylist how do i get my desire result?
List<double[]> alParent = new ArrayList<>();. Next, have a look at theArrayListdocumentation - see which of those methods sounds like it will get a specific element...List.get(index)returns item at a specific index and then select desired double value from array. for examplealParent.get(0)[0]will return fist arrays 0th element i.e. 15.22alParent.get(row)[column]is about as simple as it gets... if you want all the elements in a given column, just iterate over the rows...