if (index == -1) {  index = names.getSize(); }
    public int getNextIndex(Array n) throws Exception {        int index = -1;        Array names = getNames();        if (names != null) {            int i = index + 1;            Array name = null;            while (i < names.getSize()) {                name = names.get(i);                // If a null name is reached, then the name was not found.                // In this case, the current value of i is the next free index.                if (name == null) {                    index = i;                    break;                } else {                    // If a name equal to the searched one is found,                    // then its index is the one to be returned since                    // this element will have to be replaced.                    if (name.isEqualTo(n)) {                        index = i;                        break;                    }                }                i++;            }        } else {            throw new Exception("Could not get next free index. The names is null.");        }        return index;    }