go to previous page   go to home page   go to next page

Answer:

Just a little.


Days without Data

The constructor mostly assumes correct data. It checks the month number, but not the year. Data should be verified by the caller before using the constructor. Where and what to do for error checking and handling is often a tricky design decision.

When initially constructed, each cell of an array is initialized to a default value. The array temp[] will be filled with zeros, but these are not actual data for the days. The role of the array valid[] shows which days have data:

// temperature data
private int[] temp;    // day 1 in temp[1]
private boolean[] valid;

If (say) valid[5] is true, then the corresponding temperature for day 5 is valid.


QUESTION 5:

What value are arrays of boolean initialized to?


go to previous page   go to home page   go to next page