Stack继承于Vector,Vector则是实现了List接口,所以Stack本质上也是一个List。
Vector的存储方式也和ArrayList一样,使用数组进行存储。
protected Object[] elementData; //存储数据的数组Vector中大部分对数据操作的方法都有synchronized修饰符进行修饰,所以Vector是一个线程安全的容器。
Stack则很简单,除了父类的一些方法之外,它还提供了一些它作为栈的一些操作,例如:push(E):E、pop():E、peek():E等等。
而且这些方法都是调用父类方法进行实现的,所以,这些方法都是线程安全的。
PS: peek():E的作用是:Looks at the object at the top of this stack without removing it from the stack.