![]() |
#2
林月儿2018-09-26 16:57
|

public class test {
Object[] obj;
int size;
public int size() {
return size;
}
public test() {
this.test(5);
}
private void test(int i) {
obj = new Object[i];
}
public void add(Object o) {
if (size==obj.length) {
grow();
}
obj[size] = o;
size++;
}
private void grow() {
Object[] o = new Object[obj.length+10];
for(int i=0;i<size;i++){
o[i] = obj[1];
}
obj=o;
}
public Object get(int i) {
return obj[i];
}
public void set(int i,Object o) {
// TODO Auto-generated method stub
for(int j=size;j>i;j--){
obj[j]=obj[j-1];
}
obj[i] = o;
}
Object[] obj;
int size;
public int size() {
return size;
}
public test() {
this.test(5);
}
private void test(int i) {
obj = new Object[i];
}
public void add(Object o) {
if (size==obj.length) {
grow();
}
obj[size] = o;
size++;
}
private void grow() {
Object[] o = new Object[obj.length+10];
for(int i=0;i<size;i++){
o[i] = obj[1];
}
obj=o;
}
public Object get(int i) {
return obj[i];
}
public void set(int i,Object o) {
// TODO Auto-generated method stub
for(int j=size;j>i;j--){
obj[j]=obj[j-1];
}
obj[i] = o;
}
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录