Write a method public static ArrayList append(ArrayLista, ArrayList b) that appends one array list after another. For example, if a is 1 4 9 16 and b is 9 7 4 9 11 then append returns the array list 1 4 9 16 9 7 4 9 11. This is what I have done so far and I'm pretty sure I'm almost finished but I keep running into errors; mainly "cannot find symbol ArrayList" Can anyone help me?
import java.util.Arrays;
public class AlAppend {
public static ArrayList<Integer> append(ArrayList<Integer> a, ArrayList<Integer> b) {
ArrayList<Integer> c = new ArrayList<Integer>();
c.addAll(a);
c.addAll(b);
return c;
}
public static void main(String[] args) {
// List 1
ArrayList<Integer> array1 = new ArrayList<Integer>();
array1.add(1);
array1.add(4);
array1.add(9);
array1.add(16);
System.out.println("List 1: " + array1);
// List 2
ArrayList<Integer> array2 = new ArrayList<Integer>();
array2.add(9);
array2.add(7);
array2.add(4);
array2.add(9);
array2.add(11);
System.out.println("List 2: " + array2);
// Combined List
ArrayList<Integer> array3 = append(array1, array2);
System.out.println("Combined: " + array3);
}
}