Java??Vector???Stack?????
???????????? ???????[ 2014/3/12 10:45:37 ] ????????Vector?? Stack?? Java
????????????
????(1)public final synchronized void removeElement(Object obj)
???????????????obj?????ж???????????????????????????????????obj??????????????
????(2)public final synchronized void removeAllElement();
??????????????е????
????(3)public fianl synchronized void removeElementAt(int index)
???????index????????????
????????????????
????(1)public final int indexOf(Object obj)
??????????????????obj??????????????????obj??????±?????????obj??????-1.
????(2)public final synchronized int indexOf(Object obj??int index)
??????index????????±????????obj.
????(3)public final int lastindexOf(Object obj)
??????????β?????????????obj.
????(4)public final synchornized int lastIndex(Object obj??int index)
??????index????????±???β???????????obj.
????(5)public final synchornized firstElement()
????????????????е?obj
????(6)public final synchornized Object lastElement()
????????????????????obj
????2.Stack??
????Stack?????????????????????Vector ????????? ??????????????????????????????push ?? pop ??????????????????peek ??????????????????? empty ???????????в????????????????????search ??????
?????????????????????(FILO?? First In Last Out)??Stack??????Vector(???????)???????Vector??????????????????ζ???Stack????????????????????????????£?
public class Stack<e> extends Vector<e> {
public Stack() { }
public E push(E item) { // ??
addElement(item);
return item;
}
public synchronized E pop() { // ???
E obj;
int len = size();
obj = peek();
removeElementAt(len - 1);
return obj;
}
public synchronized E peek() { // ??????????
int len = size();
if (len == 0)
throw new EmptyStackException();
return elementAt(len - 1);
}
public boolean empty() { // ?ж????????
return size() == 0;
}
public synchronized int search(Object o) { // ???????
int i = lastIndexOf(o);
if (i >= 0) {
return size() - i;
}
return -1;
}
}
??????
???·???
??????????????????
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