I'm learning to build an directed graph data structure using adjacency lists, so I thought I'd use LinkedLists to ensure efficient linked list used and I wanted to use an array of Linked list, but I had trouble so I decided to use ArrayList of LinkedList of type Integer, but compiler complains about generics.
The problem I have is having a wrapper that adds a new vertex to the current end of a LL (so it's a wrapper for addLast(Elem e) which is really a LinkedList method)
import java.util.*; import java.lang.*; class Graph//implemented via adjacency lists { public Graph(int size) { this.size = size; l = new LinkedList(size); } public void add_to_end(Integer i)//problem here... { this.l.add(i);//PROBLEM: this.l is a Linked List data member but compiler complains... } public void print(){return;}//prints each index (so each adjacent node for a given node) public void dft(){return;}//Depth-first traversal of current graph public void bft(){return;}//breadth-first " " public int get_size(){return this.size;} private int size;//number of vertices private ArrayList l; } public class Graphs_runner { public static void main(String[] args) { } }