# JSONArray

public class **JSONArray** extends Object  
A dense indexed sequence of values. Values may be any mix of
`https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html`, other `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html`, Strings,
Booleans, Integers, Longs, Doubles, `null` or `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`.
Values may not be `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isNaN()`, `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isInfinite()`, or of any type not listed here.

`JSONArray` has the same type coercion behavior and
optional/mandatory accessors as `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html`. See that class'
documentation for details.

**Warning:** this class represents null in two incompatible
ways: the standard Java `null` reference, and the sentinel value `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`. In particular, `get` fails if the requested index
holds the null reference, but succeeds if it holds `JSONObject.NULL`.

Instances of this class are not thread safe. Although this class is
nonfinal, it was not designed for inheritance and should not be subclassed.
In particular, self-use by overridable methods is not specified. See
*Effective Java* Item 17, "Design and Document or inheritance or else
prohibit it" for further information.

### Public Constructor Summary

|---|---|
|   | [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#JSONArray())() Creates a `JSONArray` with no values. |
|   | [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#JSONArray(java.util.Collection))(Collection copyFrom) Creates a new `JSONArray` by copying all values from the given collection. |
|   | [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#JSONArray(org.json.JSONTokener))([JSONTokener](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONTokener.html) readFrom) Creates a new `JSONArray` with values from the next array in the tokener. |
|   | [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#JSONArray(java.lang.String))(String json) Creates a new `JSONArray` with values from the JSON string. |
|   | [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#JSONArray(java.lang.Object))(Object array) Creates a new `JSONArray` with values from the given primitive array. |

### Public Method Summary

|---|---|
| boolean | [equals](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#equals(java.lang.Object))(Object o) |
| Object | [get](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#get(int))(int index) Returns the value at `index`. |
| boolean | [getBoolean](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getBoolean(int))(int index) Returns the value at `index` if it exists and is a boolean or can be coerced to a boolean. |
| double | [getDouble](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getDouble(int))(int index) Returns the value at `index` if it exists and is a double or can be coerced to a double. |
| int | [getInt](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getInt(int))(int index) Returns the value at `index` if it exists and is an int or can be coerced to an int. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [getJSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getJSONArray(int))(int index) Returns the value at `index` if it exists and is a `JSONArray`. |
| [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html) | [getJSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getJSONObject(int))(int index) Returns the value at `index` if it exists and is a `JSONObject`. |
| long | [getLong](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getLong(int))(int index) Returns the value at `index` if it exists and is a long or can be coerced to a long. |
| String | [getString](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#getString(int))(int index) Returns the value at `index` if it exists, coercing it if necessary. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#hashCode())() |
| boolean | [isNull](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#isNull(int))(int index) Returns true if this array has no value at `index`, or if its value is the `null` reference or `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`. |
| String | [join](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#join(java.lang.String))(String separator) Returns a new string by alternating this array's values with `separator`. |
| int | [length](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#length())() Returns the number of values in this array. |
| Object | [opt](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#opt(int))(int index) Returns the value at `index`, or null if the array has no value at `index`. |
| boolean | [optBoolean](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optBoolean(int))(int index) Returns the value at `index` if it exists and is a boolean or can be coerced to a boolean. |
| boolean | [optBoolean](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optBoolean(int,%20boolean))(int index, boolean fallback) Returns the value at `index` if it exists and is a boolean or can be coerced to a boolean. |
| double | [optDouble](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optDouble(int))(int index) Returns the value at `index` if it exists and is a double or can be coerced to a double. |
| double | [optDouble](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optDouble(int,%20double))(int index, double fallback) Returns the value at `index` if it exists and is a double or can be coerced to a double. |
| int | [optInt](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optInt(int))(int index) Returns the value at `index` if it exists and is an int or can be coerced to an int. |
| int | [optInt](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optInt(int,%20int))(int index, int fallback) Returns the value at `index` if it exists and is an int or can be coerced to an int. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [optJSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optJSONArray(int))(int index) Returns the value at `index` if it exists and is a `JSONArray`. |
| [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html) | [optJSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optJSONObject(int))(int index) Returns the value at `index` if it exists and is a `JSONObject`. |
| long | [optLong](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optLong(int))(int index) Returns the value at `index` if it exists and is a long or can be coerced to a long. |
| long | [optLong](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optLong(int,%20long))(int index, long fallback) Returns the value at `index` if it exists and is a long or can be coerced to a long. |
| String | [optString](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optString(int))(int index) Returns the value at `index` if it exists, coercing it if necessary. |
| String | [optString](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#optString(int,%20java.lang.String))(int index, String fallback) Returns the value at `index` if it exists, coercing it if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int))(int value) Appends `value` to the end of this array. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(long))(long value) Appends `value` to the end of this array. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int,%20boolean))(int index, boolean value) Sets the value at `index` to `value`, null padding this array to the required length if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(double))(double value) Appends `value` to the end of this array. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int,%20java.lang.Object))(int index, Object value) Sets the value at `index` to `value`, null padding this array to the required length if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int,%20long))(int index, long value) Sets the value at `index` to `value`, null padding this array to the required length if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int,%20int))(int index, int value) Sets the value at `index` to `value`, null padding this array to the required length if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(boolean))(boolean value) Appends `value` to the end of this array. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(int,%20double))(int index, double value) Sets the value at `index` to `value`, null padding this array to the required length if necessary. |
| [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) | [put](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#put(java.lang.Object))(Object value) Appends `value` to the end of this array. |
| Object | [remove](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#remove(int))(int index) Removes and returns the value at `index`, or null if the array has no value at `index`. |
| [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html) | [toJSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#toJSONObject(org.json.JSONArray))([JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) names) Returns a new object whose values are the values in this array, and whose names are the values in `names`. |
| String | [toString](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#toString())() Encodes this array as a compact JSON string, such as: ``` [94043,90210] ``` |
| String | [toString](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html#toString(int))(int indentSpaces) Encodes this array as a human readable JSON string for debugging, such as: ``` [ 94043, 90210 ] ``` |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| Object | clone() |
| boolean | equals(Object arg0) |
| void | finalize() |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Constructors

#### public
**JSONArray**
()

Creates a `JSONArray` with no values.

#### public
**JSONArray**
(Collection copyFrom)

Creates a new `JSONArray` by copying all values from the given
collection.

##### Parameters

| copyFrom | a collection whose values are of supported types. Unsupported values are not permitted and will yield an array in an inconsistent state. |
|---|---|

#### public
**JSONArray**
([JSONTokener](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONTokener.html) readFrom)

Creates a new `JSONArray` with values from the next array in the
tokener.

##### Parameters

| readFrom | a tokener whose nextValue() method will yield a `JSONArray`. |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the parse fails or doesn't yield a `JSONArray`. |
|---|---|

#### public
**JSONArray**
(String json)

Creates a new `JSONArray` with values from the JSON string.

##### Parameters

| json | a JSON-encoded string containing an array. |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the parse fails or doesn't yield a `JSONArray`. |
|---|---|

#### public
**JSONArray**
(Object array)

Creates a new `JSONArray` with values from the given primitive array.

##### Parameters

| array |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

## Public Methods

#### public boolean
**equals**
(Object o)

<br />

##### Parameters

| o |   |
|---|---|

#### public Object
**get**
(int index)

Returns the value at `index`.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if this array has no value at `index`, or if that value is the `null` reference. This method returns normally if the value is `JSONObject#NULL`. |
|---|---|

#### public boolean
**getBoolean**
(int index)

Returns the value at `index` if it exists and is a boolean or can
be coerced to a boolean.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value at `index` doesn't exist or cannot be coerced to a boolean. |
|---|---|

#### public double
**getDouble**
(int index)

Returns the value at `index` if it exists and is a double or can
be coerced to a double.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value at `index` doesn't exist or cannot be coerced to a double. |
|---|---|

#### public int
**getInt**
(int index)

Returns the value at `index` if it exists and is an int or
can be coerced to an int.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value at `index` doesn't exist or cannot be coerced to a int. |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**getJSONArray**
(int index)

Returns the value at `index` if it exists and is a `JSONArray`.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value doesn't exist or is not a `JSONArray`. |
|---|---|

#### public [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html)
**getJSONObject**
(int index)

Returns the value at `index` if it exists and is a `JSONObject`.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value doesn't exist or is not a `JSONObject`. |
|---|---|

#### public long
**getLong**
(int index)

Returns the value at `index` if it exists and is a long or
can be coerced to a long.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if the value at `index` doesn't exist or cannot be coerced to a long. |
|---|---|

#### public String
**getString**
(int index)

Returns the value at `index` if it exists, coercing it if
necessary.

##### Parameters

| index |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) | if no such value exists. |
|---|---|

#### public int
**hashCode**
()

<br />

#### public boolean
**isNull**
(int index)

Returns true if this array has no value at `index`, or if its value
is the `null` reference or `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`.

##### Parameters

| index |   |
|---|---|

#### public String
**join**
(String separator)

Returns a new string by alternating this array's values with `separator`. This array's string values are quoted and have their special
characters escaped. For example, the array containing the strings '12"
pizza', 'taco' and 'soda' joined on '+' returns this:

```
"12\" pizza"+"taco"+"soda"
```

<br />

##### Parameters

| separator |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public int
**length**
()

Returns the number of values in this array.

#### public Object
**opt**
(int index)

Returns the value at `index`, or null if the array has no value
at `index`.

##### Parameters

| index |   |
|---|---|

#### public boolean
**optBoolean**
(int index)

Returns the value at `index` if it exists and is a boolean or can
be coerced to a boolean. Returns false otherwise.

##### Parameters

| index |   |
|---|---|

#### public boolean
**optBoolean**
(int index, boolean fallback)

Returns the value at `index` if it exists and is a boolean or can
be coerced to a boolean. Returns `fallback` otherwise.

##### Parameters

| index |   |
| fallback |   |
|---|---|

#### public double
**optDouble**
(int index)

Returns the value at `index` if it exists and is a double or can
be coerced to a double. Returns `NaN` otherwise.

##### Parameters

| index |   |
|---|---|

#### public double
**optDouble**
(int index, double fallback)

Returns the value at `index` if it exists and is a double or can
be coerced to a double. Returns `fallback` otherwise.

##### Parameters

| index |   |
| fallback |   |
|---|---|

#### public int
**optInt**
(int index)

Returns the value at `index` if it exists and is an int or
can be coerced to an int. Returns 0 otherwise.

##### Parameters

| index |   |
|---|---|

#### public int
**optInt**
(int index, int fallback)

Returns the value at `index` if it exists and is an int or
can be coerced to an int. Returns `fallback` otherwise.

##### Parameters

| index |   |
| fallback |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**optJSONArray**
(int index)

Returns the value at `index` if it exists and is a `JSONArray`. Returns null otherwise.

##### Parameters

| index |   |
|---|---|

#### public [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html)
**optJSONObject**
(int index)

Returns the value at `index` if it exists and is a `JSONObject`. Returns null otherwise.

##### Parameters

| index |   |
|---|---|

#### public long
**optLong**
(int index)

Returns the value at `index` if it exists and is a long or
can be coerced to a long. Returns 0 otherwise.

##### Parameters

| index |   |
|---|---|

#### public long
**optLong**
(int index, long fallback)

Returns the value at `index` if it exists and is a long or
can be coerced to a long. Returns `fallback` otherwise.

##### Parameters

| index |   |
| fallback |   |
|---|---|

#### public String
**optString**
(int index)

Returns the value at `index` if it exists, coercing it if
necessary. Returns the empty string if no such value exists.

##### Parameters

| index |   |
|---|---|

#### public String
**optString**
(int index, String fallback)

Returns the value at `index` if it exists, coercing it if
necessary. Returns `fallback` if no such value exists.

##### Parameters

| index |   |
| fallback |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int value)

Appends `value` to the end of this array.

##### Parameters

| value |   |
|---|---|

##### Returns

- this array.

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(long value)

Appends `value` to the end of this array.

##### Parameters

| value |   |
|---|---|

##### Returns

- this array.

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int index, boolean value)

Sets the value at `index` to `value`, null padding this array
to the required length if necessary. If a value already exists at `index`, it will be replaced.

##### Parameters

| index |   |
| value |   |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(double value)

Appends `value` to the end of this array.

##### Parameters

| value | a finite value. May not be `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isNaN()` or `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isInfinite()`. |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int index, Object value)

Sets the value at `index` to `value`, null padding this array
to the required length if necessary. If a value already exists at `index`, it will be replaced.

##### Parameters

| index |   |
| value | a `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html`, `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html`, String, Boolean, Integer, Long, Double, `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`, or `null`. May not be `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isNaN()` or `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isInfinite()`. |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int index, long value)

Sets the value at `index` to `value`, null padding this array
to the required length if necessary. If a value already exists at `index`, it will be replaced.

##### Parameters

| index |   |
| value |   |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int index, int value)

Sets the value at `index` to `value`, null padding this array
to the required length if necessary. If a value already exists at `index`, it will be replaced.

##### Parameters

| index |   |
| value |   |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(boolean value)

Appends `value` to the end of this array.

##### Parameters

| value |   |
|---|---|

##### Returns

- this array.

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(int index, double value)

Sets the value at `index` to `value`, null padding this array
to the required length if necessary. If a value already exists at `index`, it will be replaced.

##### Parameters

| index |   |
| value | a finite value. May not be `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isNaN()` or `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isInfinite()`. |
|---|---|

##### Returns

- this array.

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public [JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html)
**put**
(Object value)

Appends `value` to the end of this array.

##### Parameters

| value | a `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html`, `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html`, String, Boolean, Integer, Long, Double, `https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html#NULL`, or `null`. May not be `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isNaN()` or `https://developers.google.com/j2objc/javadoc/android/reference/java/lang/Double.html#isInfinite()`. Unsupported values are not permitted and will cause the array to be in an inconsistent state. |
|---|---|

##### Returns

- this array.

#### public Object
**remove**
(int index)

Removes and returns the value at `index`, or null if the array has no value
at `index`.

##### Parameters

| index |   |
|---|---|

#### public [JSONObject](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONObject.html)
**toJSONObject**
([JSONArray](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONArray.html) names)

Returns a new object whose values are the values in this array, and whose
names are the values in `names`. Names and values are paired up by
index from 0 through to the shorter array's length. Names that are not
strings will be coerced to strings. This method returns null if either
array is empty.

##### Parameters

| names |   |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|

#### public String
**toString**
()

Encodes this array as a compact JSON string, such as:

```
[94043,90210]
```

<br />

#### public String
**toString**
(int indentSpaces)

Encodes this array as a human readable JSON string for debugging, such
as:

```
 [
     94043,
     90210
 ]
```

<br />

##### Parameters

| indentSpaces | the number of spaces to indent for each level of nesting. |
|---|---|

##### Throws

| [JSONException](https://developers.google.com/j2objc/javadoc/android/reference/org/json/JSONException.html) |   |
|---|---|