This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It means that nViewerTest.movieCode has not been initialized, it's null. It seems like you've initialized it because you obtained an input from the user called MC, and you passed that String to the Viewer constructor that has a String argument called movieCode, but that argument wasn't used in the constructor. There are 2 variables with the same name. One movieCode is local to the constructor, and the other movieCode is a class Viewer instance variable.
A statement commonly seen in the constructor that would solve this problem is:
this.movieCode = movieCode;
This means that the Viewer instance variable movieCode is assigned the value passed to the constructor in the argument (local) variable movieCode.
Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Joined: Feb 29, 2012
I changed the code and I know longer have the error. Thanks