I have ArrayList<String> armArray1=[1, 2, 3, 4]
and ArrayList<String> armArray2=[5, 6, 7, 8]
. The size()
of both arrays will always be equal to each other but could have between 4 elements to 100 elements.
At each run, I need to determine the size()
of one of these arrays (since the size of both will always be equal to each other). The size in this case is 4
so I need to put the corresponding elements in both arrays into a new ArrayList
. For instance: ArrayList<String> a=[1, 5]
, ArrayList<String> b=[2, 6]
, ArrayList<String> c=[3, 7]
, ArrayList<String> d=[4, 8]
. The size()
of the arrays changes at every run and so their size needs to be determined at every run. For now, I created an ArrayList
that contains variables based on the size()
of armArray1
. I am trying to find out how I can proceed further. Any help or guidance would be highly appreciated.
//create another ArrayList that would create the variables based on the size() of armArray1
ArrayList<String> var = new ArrayList<String>();
for (int i = 1; i < armArray1.size() / 3 + 1; i++) {
var.add("arm"+i);
}
//this gives [arm1,arm2,arm3,arm4]