java - Getting NullPointerException with Object Array -
I am writing a program to mimic the "deal or no deal" game.
Background on Deal or No Deal:
In working up to the final product, I have written different sections. However, I am trying to test one of my classes, and continue to get the I wrote a class called box, which creates a "box" object. The box object is a real box that the player chooses. It has a true / false value and a double box value. I have also written another class called boxlist, it creates a box object array that will work as a sports board, when will be added with further classes which I'm planning to write. The main idea is that the constructor of the boxlist creates an array using the array as a parameter by using the I wrote a sample key to test the method, but when I try to get the value of a particular (These are pieces of a big program ... I have written so much earlier that I do not want to stop) You started your to NullPointerException.
Boolean variable indicates whether it is open / closed (true for open, false to close) The double box is the actual value assigned to the box.
public square box {// example field private double box value; // Dollar amount of private boolean open closure in each box; // Box is closed or not // Constructor public box (double box value) {this.openClose = false; this.boxValue = boxValue; If (box value & lt; 0) {setting new invalid records ("the value of the box should be greater than 0"); }}}
double arrow , and then creates a box object array of the same length of the passage in the dual array, and assign Does the double value of each element of the
parameter array , as the related element according to the box object
array .
element in a box in the box list array I get NullPointerException I can advise to help someone shoot this problem?
public class boxlists {private box [] BoxArray; Public boxlists (double [] monetary withdrawal) {box [] boxArray = new box [monetary size] length ;; For (int i = 0; i
boxer properly, but You started a local variable
boxer , and your example variable
box was redirected, so Java started it on
null , created an exception. Change
box [] boxAre = new box [monetary size] length ;;
box around = new box [monetary size. Length];
Comments
Post a Comment