Question SOLVED: Creating an array of linked lists

Question SOLVED: Creating an array of linked lists

import java.util.LinkedList;

public class testprintOut {

private static LinkedList[] array;

public static void main(String[] args) {

int nelems = 5;

array = new LinkedList[nelems];

for (int i = 0; i < nelems; i++) {

array[i] = new LinkedList<String();

}

array[0]=["ab"];

System.out.println(array[0]);

}

}

//I want to create array of linked lists so how do I create them and print them out efficiently?

//Syntax error on token "=", Expression expected after this token

Also, is this how I can put them into hashTable?

public HashTable(int size, HashType type) {

// Initialize

// HashTable(size, type, null); //QQQ

printStats = false;

this.type = type;

nelems = size;

arrayLinkedList = new LinkedList[nelems];

for (int i = 0; i < nelems; i++) {

arrayLinkedList[i] = new LinkedList<String();

}

}

//Thanks
Powered by