What is teacherList? Is it a List or an array? You seem to be treating it as a List not an array (although some Lists do contain arrays). You know that arrays only have the methods from the Object class, and the length attribute. When you set up an array it contains 0s (if a primitive array) or nulls throughout. When you set up a List it doesn't (officially) contain anything; it has all the methods in the List interface and you use size() to find how many elements it contains. You can only find a null if you have put a null in somewhere.
You can go through the List using its size() method to find how many elements it has, then you could use your for loop to find whether any of the elements is null, and there is a method in List which can replace the null with your new object.
But if you haven't put nulls in your List there won't be any nulls detectable. You will simply have to use the usual method to get another member in. It's in List and it will tell you where it puts the new element.
Tell us what you work out.
What's wrong? Where are you going? Stop! Read this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database