Gwen Smith wrote:thanks!
is it possible to use an if statement to check whether an index of an array is null?
Terminology: an index of an array is an integer number that says which element of an array is referred to. If you declare an array of 4 elements, you can refer to the individual elements in that array with the indices (or indexes) 0, 1, 2, and 3.
So an index of an array is an integer number, and it is not possible for an integer to be null. It can be 0, but that is not the same thing.
Now, if you declare an array of objects (such as an array of Contacts), thusly:
Contact contactList = new Contact[4];
That creates an array of these objects. If you were to try to refer to any one of those contact objects just after initializing the array with the above statement, you would discover that all four array elements are, in fact, null. So you could execute the following statement:
if (contactList[0] == null) { System.out.println("Yep, first one ain't here"); }
So, to go beyond this particular question and hook it up with the previous discussion: if you wanted to determine which elements of your array were already in use, you *could* use a loop to look at each element of the array in turn and, when you find one that is null, then you have found a free one that could store another contact.
There are other ways to do it that are better in some dimension, but I am trying to answer the question I think you might have been asking once we get past the teminology issue.
rc