From 3645f91b551e2806e007e5f0dbeb0cca8f493e42 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Thu, 8 Jun 2017 12:15:03 -0400 Subject: [PATCH] change JSONArray(Collection) constructor to use the default capacity when a null collection is passed --- JSONArray.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/JSONArray.java b/JSONArray.java index 0853d00..531b89d 100644 --- a/JSONArray.java +++ b/JSONArray.java @@ -154,8 +154,10 @@ public class JSONArray implements Iterable { * A Collection. */ public JSONArray(Collection collection) { - this.myArrayList = new ArrayList(collection == null ? 0 : collection.size()); - if (collection != null) { + if (collection == null) { + this.myArrayList = new ArrayList(); + } else { + this.myArrayList = new ArrayList(collection.size()); for (Object o: collection){ this.myArrayList.add(JSONObject.wrap(o)); }