• Post Reply Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception  RSS feed

 
Rose Jac
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dijkstra algorithm:
What changes should i make?



output:
run:
vertices map {1=A, 2=B, 3=C, 4=D, 5=E}
Exception in thread "main" java.lang.NullPointerException
adjacencyMap {E={D=1}, A={B=1, C=1}, B={D=1, A=1}, C={D=1, A=1}}
E
A
Q [B, C]
processed [A]
at simulation.Dijkstra.doDijkstra(Dijkstra.java:73)
at simulation.Dijkstra.<init>(Dijkstra.java:43)
at simulation.Dijkstra.main(Dijkstra.java:155)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)


help please!
 
Rose Jac
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I figured it out. I forgot to add D's directadjacentnodes.
Thanks!
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you put this code into a debugger. Most of them allow you to set a break for unhandled exception, set one for null pointer and see where the deref of the null is.

I don't know if you're truncating the information or what, but mostly java exceptions can/do produce stack traces, which include the line number of the line where the exception occurred.

You do not say whether you know what a null pointer exception is, or what attempts you have made to figure out your problem. I am not inclined to debug your program for you from scratch; this forum really does better with more specific questions than "what's wrong here?", though the worst of those don't even give the output.

Do you have/use eclipse, netbeans, or something similar? Do you have any way of stepping through your code?

rc
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!