import java.util.ArrayList;
public class XMArray {
private Object[] XMArray = new Object[0];
public void push(Object obj) {
Object bak[] = XMArray;
XMArray = new Object[XMArray.length + 1];
for (int i = 0; i < bak.length; i++) {
XMArray[i] = bak[i];
}
XMArray[XMArray.length - 1] = obj;
}
public Object get(int i) {
return XMArray[i];
}
public void remove(int i) {
XMArray[i] = "00%0*0(0$0#@_!)*&^%$OpFGJjasd+";
String flag = "00%0*0(0$0#@_!)*&^%$OpFGJjasd+";
Object bak[] = XMArray;
XMArray = new Object[XMArray.length - 1];
for (int j = 0; j < bak.length; j++) {
if (((String) bak[j]).equals(flag)) {
XMArray[j] = bak[j + 1];
} else if (j == bak.length - 1) {
XMArray[j - 1] = bak[j];
} else {
XMArray[j] = bak[j];
}
}
}
public void set(int i, Object obj) {
XMArray[i] = obj;
}
public Object pop() {
Object obj = null;
try {
obj = XMArray[0];
Object[] obj2 = new Object[XMArray.length - 1];
for (int i = 0; i < XMArray.length - 1; i++) {
obj2[i] = XMArray[i + 1];
}
XMArray = obj2;
return obj;
} catch (Exception e) {
return obj;
}
}
public static void main(String[] args) {
XMArray a = new XMArray();
a.push("a");
a.push("b");
a.push("c");
a.pop();
a.pop();
//a.pop();
//a.pop();
for (int i = 0; i < a.XMArray.length; i++) {
System.out.println(a.get(i));
}
}
}
私人数组【2】
最新推荐文章于 2022-02-14 20:15:41 发布