I'm writing a Java program with an object containing an array and indices first
and last
to represent positions in the array where values are defined. So for instance if a double array of length 8 is supposed to be blank except at the 3rd, 4th, and 5th coordinates, like [_, _, _, -1.0, 4.2, -5.9, _, _]
then first
will store 3 and last
will store 6 (one more than the last position where values are defined). However, I don't know how to have null values inside a Java array. It initializes everything to 0.0 and I'm not able to assign null values to any coordinates.
I'm required to use arrays for this task and an array of all 0.0s is supposed to be regarded as full, so I can't just choose to interpret that as empty.
Thanks for any help.