Click to See Complete Forum and Search --> : [RESOLVED] generic class


fireatmyself
November 15th, 2009, 04:58 AM
Hello.

I want to make a generic list class for, let's say, storing a graph. For each node (raging from 1 to n) I keep a linked list for it's neighbors. But I don't want to make an array of lists. I want to use the generic class for making a linked list of linked lists. Roughly speaking, I want to obtain something like this: myList< myList<Integer> > Graph. How can I do it?

I will post a part of the code, to be more precise:


class Node<T>{
T key;
Node<T> prev, next;

Node(T val) {
key = val;
}
}

class List<T extends Comparable<T>> {
Node<T> First, Last;

void insert(T val) { ... }
void write() { ... }
}

class myMain {
public static void main(String arg[]) {

List< something > Graph = new List< something >();
....
} }


Thank you for your help.