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 NullPointerException.

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. 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"); }}}   

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 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 .

I wrote a sample key to test the method, but when I try to get the value of a particular element in a box in the box list array I get NullPointerException I can advise to help someone shoot this problem?

(These are pieces of a big program ... I have written so much earlier that I do not want to stop)

  public class boxlists {private box [] BoxArray; Public boxlists (double [] monetary withdrawal) {box [] boxArray = new box [monetary size] length ;; For (int i = 0; i    

You started your 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 ;;   

to

  box around = new box [monetary size. Length];    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -