I have two ArrayLists
private ArrayList<ArrayList<String> dataList = new ArrayList<>();
//This is a class variable
ArrayList<String> dataRow = new ArrayList<>();
//This is a method variable
I add items to dataRow
dataRow.add("number");
dataRow.add("firstName");
dataRow.add("surname");
dataRow.add("dateStart");
dataRow.add("dateEnd");
and then I add each dataRow to dataList resulting in an ArrayList of ArrayLists
dataList.add(dataRow);
My Question is:
I need to select just elements 3 and 4 from each dataRow and I can't find any code that works.
I have tried
for (ArrayList<String> eachRow : dataList)
{
For (String eachElement : eachRow)
(
System.out.println(eachElement)
}
}
All this does is print out all the elements
I have also tried other code such as
dataList.get(eachElement)
this throws a no suitable method error in netbeans
I worked it out as soon as I had posted this.
The code in the inner for loop should be:
System.out.println(eachRow.get(4));