Java??Vector???Stack?????
???????????? ???????[ 2014/3/12 10:45:37 ] ????????Vector?? Stack?? Java
????Vector??capacityIncrement????0?????capacityIncrement??С???????????????2?????????ù???????new???Vector????????capacityIncrement???????????????????2????
private void grow(int minCapacity) {
// overflow-conscious code
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + ((capacityIncrement > 0) ?
capacityIncrement : oldCapacity);
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity - MAX_ARRAY_SIZE > 0)
newCapacity = hugeCapacity(minCapacity);
elementData = Arrays.copyOf(elementData?? newCapacity);
}
????Vector?????????????
public Vector(int initialCapacity?? int capacityIncrement) {
super();
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal Capacity: "+
initialCapacity);
this.elementData = new Object[initialCapacity];
this.capacityIncrement = capacityIncrement;
}
public Vector(int initialCapacity) {
this(initialCapacity?? 0);
}
public Vector() {
this(10);
}
????Vector???????
???????????
??????1??public final synchronized void adddElement(Object obj)
??????obj??????????β????obj???????κ?????????????????????????????????в?????????????????????????????????????????????????????????????????
???????磺?????????1????????????v1.addElement(1)?????????????
????Vector v1 = new Vector();
????Integer integer1 = new Integer(1);
????v1.addElement(integer1);
????(2)public final synchronized void setElementAt(Object obj??int index)
??????index??????????ó?obj?????????????????
????(3)public final synchronized void insertElement(Object obj??int index)
??????index?????λ?ò???obj???????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11