Hi guys,
I was hoping someone can help me. I've been stuck on a problem for some time and I can't seem to find the solution.
My task is to take elements from a List<string> and put them into a generic linked list.
I've figured out how to use the listIterator and used that to cycle through all the names.
It works as long as I put in System.out.println(x); to the screen.
When I try to place the values into the LinkedList I get a never ending NullPointerException.
Here's the code if it helps:
//from main in a main source
List<String> words3 = Collections.unmodifiableList(names2);
aLinkedList wordlist = new LinkedList(names3);
System.out.println();
//from the linkedlist source
public aLinkedList(List<String> words){
ListIterator<String> itr = words.listIterator();
while (itr.hasNext()) {
String name = itr.next();
// System.out.println(words);
LLWords.add(words);
// for(String word : words) {
// System.out.println(words);
// }
}
I was trying different things and that's what the //'s were for. Thanks for any help.
-J