1

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.

1 Answers1

2

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.

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
  • I have never had to use null before in a program (i am newbie) so not sure how this would work. Is their any tutorials you could point me to peter.petrov – user3493849 Apr 06 '14 at 21:15
  • The null value is a simple thing. Check this for example: http://stackoverflow.com/questions/2707322/what-is-null-in-java – peter.petrov Apr 06 '14 at 21:44