• Post Reply Bookmark Topic Watch Topic
  • New Topic

Null pointer exception in linkedlist  RSS feed

 
Samir Raut
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm getting NullPointerException in the searchLinkedList method. I goes to the last node and whe it reaches L = L.next it throws the exception. I don't know how to go about this. I understand the issue but don't know how to solve it.


 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like your text posted in the middle of your Node class. After I pasted it together and ran it, I don't get an error.

In the future, be sure to post the code you're running and post it correctly. Then post the stack trace of the error you're getting. The line number in the stack trace should match the line number in the code you post.
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be that I added code tags wrongly. I saw those two Exceptions and thought they constituted a break in the code. Sorry.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!