code: public int optInt(int index, int defaultValue) {
          final Number val = this.optNumber(index, null);
          if (val == null) {
              return defaultValue;
          }
          return val.intValue();
      }
docs: Get the optional int value associated with an index. The defaultValue is
  returned if there is no value for the index, or if the value is not a
  number and cannot be converted to a number.
  
  @param index
  The index must be between 0 and length() - 1.
  @param defaultValue
  The default value.
  @return The value.