Saturday, November 14, 2009

Plz help with circular linked list... in java?

is this enough to make a linked list circular.....


--------------------------------------...


void circular()


{


node temp=start;


while(temp.next!=null)


temp=temp.next;


temp.next=start;


}


--------------------------------------...


where start is the head of the linked list.... it takes input for the linked list and works fine untill the method circular is called and gives the following error :-


--------------------------------------...


Exception in thread "main" java.lang.NullPointerException


at method.display(joseph.java:48)


at joseph.main(joseph.java:89)


--------------------------------------...


joseph is the name of the class in which main resides

Plz help with circular linked list... in java?
I don't know about circular linked list much. But what I do know is that in a circular linked list, the first node is connected to the last node.








The exception NullPointerException occurs when you have an object and the object points to a null value.


Here's a better explanation:





http://forum.java.sun.com/thread.jspa?th...





Good luck.
Reply:Looks like you are getting the Null reference exception in the method named display


at method.display(joseph.java:48) and not circular

fake teeth

No comments:

Post a Comment