If you have an ArrayList (named al
in this case), and you're looking to get the first five elements of the list as variables, you could do this:
String x1 = al.get(0);
String x2 = al.get(1);
String x3 = al.get(2);
String x4 = al.get(3);
String x5 = al.get(4);
However, using a for loop, is there a way you could do something like this instead:
for (int i = 1; i < 6; i++){
String namer = "x" + i.toString();
String [value of String 'namer'] = al.get(i-1);
}
Or is there a completely different method that is much more efficient?