GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.NullPointerException" Watch "Exception in thread "main" java.lang.NullPointerException" New topic
Author

Exception in thread "main" java.lang.NullPointerException

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245





$ 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

Joined: Apr 23, 2009
Posts: 159

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.


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Nico Van Brandt
Ranch Hand

Joined: Mar 31, 2011
Posts: 66

A constructor does not have return type void in the signature.
It should be:



Oracle Java SE6 Certified Programmer
Oracle Java EE5 Certified Web Component Developer
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
Does the API description for this method help?
 
GeeCON Prague 2014
 
subject: Exception in thread "main" java.lang.NullPointerException