Does declaration of an object array automatically initialize it's elements?
This line does not mean that Class8C is an array filled with new Result objects. It means that Class8C is a new array object that can hold Result objects, however, each element is null. You have to assign each element an actual Result object.
Mark Patrick<br />SCJP 1.4
Joined: Nov 13, 2004
Can I request you to please help me out by providing a few lines of code on how to "assign each element an actual Result object." in this program.
Here you (perhaps incorrectly -- more in a minute) assign a number to each element of an array:
You just have to do the same thing, but using "new" to create a Result object for each element; you've already shown in a comment how to create a single Result, you just have to do it the same way and assign them to the array elements. I don't want to simply write the code, as puzzling it out yourself has some benefits, and you're already quite close.
As for the "perhaps" incorrect part: note that the first element of a Java array is element 0, but this loop only assigns values to elements 1, 2, 3, 4 (because 4 is less than 5.) You actually want the lower limit of your loop to be at 0, not 1, so that all 5 values get assigned.