• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError with link list  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All...
I created a link list class...and here is a portion of the code, and in it , I have a method called
moveToFront(Object key), basically it would go through each node in the link list, and find if there is a node that has a matching key, if it does, it would move it to the front of the list and return true, if it doesnt, it would just return false


Bascially , I have debugged my program and isolated to this method, and I am pretty sure the following line in the code is giving me grief, basically after a matching key is found in the link list,
so ptr2 points to the matching node, and ptr1 points to the previous node, all i did was set ptr1.next to ptr2.next, and then set ptr2.next to head, and then assign ptr2 to head.

However, when I was in debugging mode, and as soon as i ran the line
ptr2.setNext(head), the node that the head points to become infinte, for example
suppose "head" is pointing to a node whose next element is null, but as soon as i run ptr2.setNext(head), the next element of the node(the one that head is pointing to) is no loger null, and it will points to another element...
I dont understand why it is doing that.....can some body PLEASE help??? many thanks...
 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just in case you are curious as why i am not using java.util.LinkList...
i am doing the project for a student i am tutoring..and the project spec said you are NOT allowed to use java.util.linklist...


Hope someone can help me out really fast though...this problem is driving me nuts...


many thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!