View Single Post
Old Nov 5th, 2006, 11:12 AM   #8
_James_
Newbie
 
Join Date: Sep 2006
Location: UK
Posts: 20
Rep Power: 0 _James_ is an unknown quantity at this point
I think i may have got it...

Generics in java are retarded so it took me a while to work it out

This appears to work but dont kill me if it blows the whole java VM up.

Note: this only works with Java 1.5

        LinkedList[] graph = new LinkedList[100];
        for(int i = 0; i != graph.length; i++)
        {
            //Java needs a class as a type paramater not a primative
            // so i used Integer. It should autobox/unbox for you. 
            graph[i] = new LinkedList<Integer>();
        }
        //this appears to work without thowing an exception. 
        graph[0].addLast(99);
_James_ is offline   Reply With Quote