Results 1 to 3 of 3
Thread: HashTable problem
- 12-16-2007, 04:49 PM #1
Member
- Join Date
- Oct 2007
- Posts
- 9
- Rep Power
- 0
HashTable problem
Hi I have to make a HashTable.And I want to implement it by declaring an array of LinkedLists<Object> where the Object is a Connection struct that contains two strings.I declare it like this:
private LinkedList<Connection>[] Connections;
public HashTable(int m) {
this.n = 0;
this.m = m;
//this.HS = hs;
for (int i = 0; i < m; i++) {
this.Connections[i] =new LinkedList<Connection> ();
}
}
But its wrong and if I try the usual:
private LinkedList<Connection>[] Connections=new LinkedList<Connection> [size];
It throws a cannot create generic array of LinkedList<Connection>.
What can I do to fix it????
- 12-16-2007, 10:05 PM #2
Java Code:int size = 5; // an array of Connections Connection[] connections = new Connection[size]; // a LinkedList of Connections LinkedList<Connection> list = new LinkedList<Connection>(); // an array of LinkedLists LinkedList[] lists = new LinkedList[size];
- 12-16-2007, 10:27 PM #3
Member
- Join Date
- Oct 2007
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
HashTable vs HashMap
By bugger in forum New To JavaReplies: 7Last Post: 01-06-2011, 03:15 PM -
Working with Key-Value Pairs in a Hashtable
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:44 PM -
Hashtable example
By Java Tip in forum Java TipReplies: 0Last Post: 02-15-2008, 08:43 AM -
Hashtable-put method
By new_1 in forum New To JavaReplies: 1Last Post: 12-23-2007, 07:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks