Created
July 10, 2013 06:53
-
-
Save lichenbo/5964001 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public ArrayList(int initialCapacity) { | |
super(); | |
if (initialCapacity < 0) | |
throw new IllegalArgumentException("Illegal Capacity: "+ | |
initialCapacity); | |
this.elementData = new Object[initialCapacity]; | |
} | |
public ArrayList() { | |
this(10); | |
} | |
public ArrayList(Collection<? extends E> c) { | |
elementData = c.toArray(); | |
size = elementData.length; | |
// c.toArray might (incorrectly) not return Object[] (see 6260652) | |
if (elementData.getClass() != Object[].class) | |
elementData = Arrays.copyOf(elementData, size, Object[].class); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment