View Single Post
Old Nov 5th, 2006, 11:12 AM   #9
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by deanosrs View Post
See when I put the <int>'s there I get the error: "found: int, required: reference" and also "generic array creation", I really don't know whats going on with it...
What version of Java are you using? The <object> syntax only works with version 1.5. (edit: Oh, and it seems like Java's autoboxing doesn't extend to generic typing, so it's <Integer> and not <int>, as _James_ points out)

Also, there isn't any code in which you instantiate your LinkedLists. Arrays of objects are created empty. You have to populate them first. For instance:
java Syntax (Toggle Plain Text)
  1. LinkedList[] graph = new LinkedList[100]; // empty array of type LinkedList
  2.  
  3. for (int i = 0; i < graph.length; i++) // populate array with LinkedLists
  4. graph[i] = new LinkedList();
This is something that frequently confuses people. Personally, I don't think Java's the best language to teach people with, as it does have a few unintuitive parts to it for those unfamiliar with low level languages.
Arevos is offline   Reply With Quote