下面的代码是从 google io 开源中获取的。
com.google.android.apps.iosched.util.Lists.java http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/util/Lists .java
public static <E> ArrayList<E> newArrayList(E... elements) {
int capacity = (elements.length * 110) / 100 + 5;
ArrayList<E> list = new ArrayList<E>(capacity);
Collections.addAll(list, elements);
return list;
}
com.google.android.apps.iosched.util.Sets.java http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/util/Sets .java
public static <E> HashSet<E> newHashSet(E... elements) {
int capacity = elements.length * 4 / 3 + 1;
HashSet<E> set = new HashSet<E>(capacity);
Collections.addAll(set, elements);
return set;
}
容量变量应该是什么意思?提前致谢!