1 Star 0 Fork 0

schwarizard / Chapter 9

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ArrayList 572 Bytes
一键复制 编辑 原始数据 按行查看 历史
schwarizard 提交于 2016-04-03 21:36 . new file
import java.util.Arrays;
public class ArrayList<E>{
private Object[] elems;
private int next;
public ArrayList(int capacity) {
elems = new Object[capacity];
}
public ArrayList() {
this(16);
}
public void add(E e) {
if(next == elems.length) {
elems = Arrays.copyOf(elems, elems.length * 2);
}
elems[next++] = e;
}
public E get(int index) {
return (E) elems[index];
}
public int size() {
return next;
}
}
Java
1
https://gitee.com/schwarizard/Chapter-9.git
git@gitee.com:schwarizard/Chapter-9.git
schwarizard
Chapter-9
Chapter 9
master

搜索帮助