May 2021 3 113 Report
Java Graph Adjacency List error java.lang.NullPointerException?

I am creating an Graph using Adjacency Lists. However I am getting an error:

Exception in thread "main" java.lang.NullPointerException.

According to the error, it seems to be in the printGraph() function.

at graph.Graph.printGraph(Graph.java:120)

at graph.Graph.main(Graph.java:160)

Someone was able to help me and suggested the "try-catch". This removed the error, however it seems my printGraph() function still doesn't work. I think I might have an error with creating an object but I do not know how to fix this. Thank you!

Link to code:

https://stackoverflow.com/questions/48899811/graph...


Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments




Helpful Social

Copyright © 2024 Q2A.MX - All rights reserved.