It prints always the same address for the pointers. Here it is:
private void printInReverse() {
MyListElement tmpElement = firstElement;
while (tmpElement.nextElement != null)...
Type: Posts; User: krafterwerk
It prints always the same address for the pointers. Here it is:
private void printInReverse() {
MyListElement tmpElement = firstElement;
while (tmpElement.nextElement != null)...
It's not. Exactly, it's only printing my last element because I don't know how to get the previousElement pointer to actually point to an element's previous element.
It stops when the prev link is null because it's when the first element of the list is reached so the list was percurred.
Yes I know. I mean, I'm not managing to make my previousElement to effectively point to an element's previous element. I guess you'll understand better if I post the code:
private void...
Okay, got it. But how could I get the previousElement from my lastElement? I tried to do create an auxElement variable, storing firstElement and progressing through the list until lastElement is null...
Okay, got it. But how could I declare a variable that points to the last element in the list? Thank you.
I've been stuck for the last couple hours trying to understand why the "printInReverse" method is getting into an infinite loop. I have no idea. I was supposed to make a double linked list that you...