diff options
author | Elliott Hughes <enh@google.com> | 2013-07-09 16:56:25 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-07-09 16:56:25 -0700 |
commit | 609601075ec0934cb23783c0b1194ecde041b6f5 (patch) | |
tree | 5e566bb2b3c593aff6022856c5b4615ba81383a8 /json/src/main/java | |
parent | 131dcd13038e931d75cd3a63d14df0527670f7f3 (diff) | |
download | libcore-609601075ec0934cb23783c0b1194ecde041b6f5.zip libcore-609601075ec0934cb23783c0b1194ecde041b6f5.tar.gz libcore-609601075ec0934cb23783c0b1194ecde041b6f5.tar.bz2 |
Implement JSONArray.remove.
Bug: https://code.google.com/p/android/issues/detail?id=53461
Change-Id: I2b920fa8d63bcc8f1260669d72e33833bbd81ced
Diffstat (limited to 'json/src/main/java')
-rw-r--r-- | json/src/main/java/org/json/JSONArray.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/json/src/main/java/org/json/JSONArray.java b/json/src/main/java/org/json/JSONArray.java index a885125..8b7d0af 100644 --- a/json/src/main/java/org/json/JSONArray.java +++ b/json/src/main/java/org/json/JSONArray.java @@ -276,6 +276,17 @@ public class JSONArray { } /** + * Removes and returns the value at {@code index}, or null if the array has no value + * at {@code index}. + */ + public Object remove(int index) { + if (index < 0 || index >= values.size()) { + return null; + } + return values.remove(index); + } + + /** * Returns the value at {@code index} if it exists and is a boolean or can * be coerced to a boolean. * |