forked from stleary/JSON-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development for stleary#516 completed with rebased repository
- Introduced JSONObject(int) constructor. - int > Initial capacity of the underlying data structure - Test for new introduced JSONArray(int) constructor. 1. Checked with input parameter: 0 2. Checked with input parameter: positive number 3. Checked with positive number input parameter and compared length 4. If input parameter is negative number JSONException is thrown: JSONArray initial capacity cannot be negative.
- Loading branch information
1 parent
19bb6fd
commit d088cf0
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,6 +205,22 @@ public JSONArray(Object array) throws JSONException { | |
} | ||
} | ||
|
||
/** | ||
* Construct a JSONArray with the specified initial capacity. | ||
* | ||
* @param initialCapacity | ||
* the initial capacity of the JSONArray. | ||
* @throws JSONException | ||
* If the initial capacity is negative. | ||
*/ | ||
public JSONArray(int initialCapacity) throws JSONException { | ||
if (initialCapacity < 0) { | ||
throw new JSONException( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
viveksacademia4git
Author
Owner
|
||
"JSONArray initial capacity cannot be negative."); | ||
} | ||
this.myArrayList = new ArrayList<Object>(initialCapacity); | ||
} | ||
|
||
@Override | ||
public Iterator<Object> iterator() { | ||
return this.myArrayList.iterator(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It may be default capacity, not error throwing.