Hello,
Please help me review the following Java code because I get the following error: Exception in thread "main" java.lang.NullPointerException
at SolarSystem.getSolarSystemMoonCount(SolarSystem.java:36)
at Driver.main(Driver.java:39)
I can't see to figure out why the variable has a value of null..
I need output to be similar to this:
You Have 9 Planets In Your REAL Solar System and 178 Moons
The Planet Mercury Has 0 Moon(s)
The Planet Venus Has 0 Moon(s)
The Planet Earth Has 1 Moon(s)
The Planet Mars Has 2 Moon(s)
The Planet Jupiter Has 67 Moon(s)
The Planet Saturn Has 62 Moon(s)
The Planet Uranus Has 27 Moon(s)
The Planet Neptune Has 14 Moon(s)
The Planet Pluto Has 5 Moon(s)
You Have 9 Planets In Your VIRTUAL Solar System and 268171150 Moons
The Planet Walmart Has 4444311 Moon(s)
The Planet KMart Has 13342321 Moon(s)
The Planet Target Has 13344411 Moon(s)
The Planet Dollar General Has 134555111 Moon(s)
The Planet Family Dollar Has 6704994 Moon(s)
The Planet Dollar Tree Has 62272772 Moon(s)
The Planet Walgreens Has 27717272 Moon(s)
The Planet CVS Has 141662 Moon(s)
The Planet Costco Has 5648296 Moon(s)
Thank you so much for your help!!
 1
You have defined plants as a reference to an array of type Planet, but you do not have an array yet. You need to do this:
before you actually have an array that is referenced by the variable planets.
Robert Partridge wrote:
Hello,
Please help me review the following Java code because I get the following error: Exception in thread "main" java.lang.NullPointerException
at SolarSystem.getSolarSystemMoonCount(SolarSystem.java:36)
at Driver.main(Driver.java:39)
I can't see to figure out why the variable has a value of null..
I need output to be similar to this:
You Have 9 Planets In Your REAL Solar System and 178 Moons
The Planet Mercury Has 0 Moon(s)
The Planet Venus Has 0 Moon(s)
The Planet Earth Has 1 Moon(s)
The Planet Mars Has 2 Moon(s)
The Planet Jupiter Has 67 Moon(s)
The Planet Saturn Has 62 Moon(s)
The Planet Uranus Has 27 Moon(s)
The Planet Neptune Has 14 Moon(s)
The Planet Pluto Has 5 Moon(s)
You Have 9 Planets In Your VIRTUAL Solar System and 268171150 Moons
The Planet Walmart Has 4444311 Moon(s)
The Planet KMart Has 13342321 Moon(s)
The Planet Target Has 13344411 Moon(s)
The Planet Dollar General Has 134555111 Moon(s)
The Planet Family Dollar Has 6704994 Moon(s)
The Planet Dollar Tree Has 62272772 Moon(s)
The Planet Walgreens Has 27717272 Moon(s)
The Planet CVS Has 141662 Moon(s)
The Planet Costco Has 5648296 Moon(s)
Thank you so much for your help!!
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
