You are viewing a single comment's thread from:

RE: Coding challenge #2 We need to go deeper

in #programming7 years ago

So, I have spent the last few hours redoing the code (I am still new to Programming) and basically had to change all of it.

Now I keep getting a null pointer exception, where just a bit ago, I wasn't. Right when the user needs to hit a number 1-4 to choose the genre of the movie.

Before this, it ran fine until I asked the user if they would like to enter another movie. That throws an exception about a missing element. I am putting the code up.

https://pastebin.com/w1qQY5aM

Please take a look and help me to understand what happened.

I put comments in the code regarding the issue.

Thank You,

Gene @btcworker

Sort:  

Hi @btcworker, the issue is that:

private static ArrayList"Movie" movieA;

Is not initialized you have to do:

private static ArrayList"movie" movieA = new Arraylist""();

Additionally, I would create the class "Movie" in a separate file and call it from another file with the main class.

This is not only important for readability but will also help us to extend the program later on.

Keep on coding!

P.S: I had to remove the > and the < tags because steemit doesn't like them =)

Besides that your variables in the movie should not be static

Thanks for the help on it. The only reason I didn't create it in a separate file/class was because i thought it was supposed to be one file.

I also already posted my solution in the next challenge or if you need any more help, just ask =)

Coin Marketplace

STEEM 0.19
TRX 0.13
JST 0.028
BTC 65178.97
ETH 3261.27
USDT 1.00
SBD 2.68