user3493849
user3493849

Reputation: 29

Searching for an empty element in an array

I have been trying to write a program that searches for an empty space in an array and will insert a value in to that space. I understand how to do a linear search to find a number that exits in an array but can't understand how to find a empty space. if any one can give me any suggestions at all I would be very grateful.

Upvotes: 1

Views: 128

Answers (1)

peter.petrov
peter.petrov

Reputation: 39457

The way it stands now, you cannot make a distinction between a 0 value you put,
and a 0 value which was there by default (a long array is initialized with zeros by default).
So I would probably just define this array as static Long array[]; and treat null as a missing value.

Upvotes: 2

Related Questions