Results 1 to 8 of 8
- 03-10-2011, 01:22 AM #1
NullPointer adding an item to a LinkedList
I am trying to perform the following operation:
- 03-10-2011, 01:34 AM #2
Either temp or temp[WhichPositionInList] or possibly posPlusVal is null. Difficult to tell without seeing more code.
- 03-10-2011, 01:49 AM #3
thats the frustrating part, I have:
System.out.println("adding at position: "+WhichPositionInList); System.out.println("temp size is: "+temp.length); System.out.println("posPlusVal is: "+posPlusVal); temp[WhichPositionInList].add(posPlusVal);
WhichPositionInList = 0;
temp size = 2;
posPlusVal ="10 5";
- 03-10-2011, 01:53 AM #4
- 03-10-2011, 02:59 AM #5
well....I thought I was adding an element to the WhichPositionInList(th) list in my array?
- 03-10-2011, 03:03 AM #6
so I guess what I'm saying is, if I have:
LinkedListArray myArray = new LinkedList;
when I do:
myArray[somePosition].add(String) it shouldnt matter whats in the list, im just appending a node, I didnt think you had to initialize each list in the listARray
- 03-10-2011, 03:13 AM #7
figured it out...
I have to create the lists individually, and I was trying to stuff a string into a list that hadnt been created..duh.
- 03-10-2011, 03:39 AM #8
- By warchieflll in forum New To JavaReplies: 10Last Post: 12-09-2010, 04:34 PM
- By kipcorn91 in forum AWT / SwingReplies: 5Last Post: 10-28-2010, 11:19 PM
- By teppel in forum New To JavaReplies: 0Last Post: 07-10-2010, 08:38 PM
- By bdario1 in forum New To JavaReplies: 15Last Post: 03-17-2010, 04:44 AM
- By fiero in forum JavaServer Pages (JSP) and JSTLReplies: 6Last Post: 11-07-2008, 01:44 PM