This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 157

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: 37874
    
  22
Does the API description for this method help?
 
 
subject: Exception in thread "main" java.lang.NullPointerException
 
Similar Threads
"Position" Concept as it applies to Data Structures
non duplicates in a Set
cannot find symbol
July Newsletter Puzzle (Maze Solver)
read input from text file