• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.NullPointerException

 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





$ javac Vertex.java
$ javac DFS.java
$ java DFS

Exception in thread "main" java.lang.NullPointerException
at DFS.toplogicalSort(DFS.java:71)
at DFS.main(DFS.java:80)
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Albert, you forgot to ask a question.

Just out of curiosity, why are you only using positions 1 - 5 in your Vertex array? The first index in a Java array is 0.
 
Nico Van Brandt
Ranch Hand
Posts: 68
IntelliJ IDE Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A constructor does not have return type void in the signature.
It should be:

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the API description for this method help?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic