code: public JSONArray element( int index, Collection value, JsonConfig jsonConfig ) {
        if( value instanceof JSONArray ){
           if( index < 0 ){
              throw new JSONException( "JSONArray[" + index + "] not found." );
           }
           if( index < size() ){
              elements.set( index, value );
           }else{
              while( index != size() ){
                 element( JSONNull.getInstance() );
              }
              element( value, jsonConfig );
           }
           return this;
        }else{
           return element( index, _fromCollection( value, jsonConfig ) );
        }
     }
docs: Put a value in the JSONArray, where the value will be a JSONArray which is
  produced from a Collection.
  
  @param index The subscript.
  @param value A Collection value.
  @return this.
  @throws JSONException If the index is negative or if the value is not
  finite.