In: Computer Science
Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks.
import java.util.ArrayList;
import java.util.LinkedList;
public class ArrayListReview<T> {
//T stands for "Type"
// Generic type ArrayList and linkedList
// Create an ArrayListReview class with one data field of
ArrayList and one with LinkedList with the generic type passed to
the class.
private ArrayList<T> arrayList;
private LinkedList<T> linkedList;
//Create a constructor that populate an array list and
the LinkedList filled with the generic type through inserting new
elements into the specified location index-i in the list.
ArrayListReview(int index,T value){
arrayList=new
ArrayList<T>(index);
linkedList=new
LinkedList<T>();
for(int
i=0;i<index;i++){//populating values with the passed value until
index
arrayList.add(value);
linkedList.add(value);
}
}
}