The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Creating an array in constructor ... defaults all values?

For some reason I am having a very difficult time trying to initialize and store values in arrays within a constructor. When I use the debugger to check the arrays values, the Boolean all default to false and my other double array all default to 0s.

I figured the arrays default because I declare them twice, but if I don't, then I just get an error...Can someone direct me the correct way of getting my arrays correctly initialized. I should mention that I have two classes, one is the tester and this is the class that is called with the methods. I prefer that no more parameters be added to the constructor.

Re: Creating an array in constructor ... defaults all values?

You need to define the variables at the class level and assign them values in the constructor.
You are defining two different variables with the same names. When the constructor exits, the local variables: huy and rup go away.

You can probably move the definitions from the constructor to the class level and replace the class level definitions with the moved ones.