好像之前在 thinking in java中看到过说Stack类继承于Vector,而这两个类都不推荐使用了,但是在做一到OJ题时,我用LinkedList来模拟栈和直接用Stack,发现在进行入栈出栈操作时Stack的速度竟然还快一点,有点疑惑了..
PHPz2017-04-17 14:46:24
Use the appropriate data structure for the appropriate scenario.
I have only used Stack when doing formula calculations, but I rarely use it at other times and it has no impact. So it still depends on your business scenario, and you should use it.
怪我咯2017-04-17 14:46:24
Not recommended
The advantage is thread safety, so single-threaded ArrayList and the like are better.
However, when multi-threading is needed, there are Collections.synchronizedList and the java.util.concurrent package. So forget about this thing.
怪我咯2017-04-17 14:46:24
When the sample size of computationally intensive code is small, the accidental error of performance testing is relatively large