bson/src/main/org/bson/types/BasicBSONList.java
public Object put(final int key, final Object value) {
        while (key >= size()) {
            add(null);
        }
        set(key, value);
        return value;
    }
public Object put(final int key, final Object value) {
        while (key >= size()) {
            add(null);
        }
        set(key, value);
        return value;
    }
Puts a value at an index. This will fill any unset indexes less than {@code index} with {@code null}.

@param key the index at which to insert the value
@param value   the value to insert
@return the value