简体   繁体   中英

Why is java.util.Stack not marked as deprecated?

There are many criticisms against the stale java.util.Stack class such as this one , saying that it should be avoided because it's less safe and less fast. I can understand keeping it in rt.jar for compatibility reasons (even we're going to keep it forever), but why isn't it marked as deprecated?

People are getting deceived by the class' name and use it everywhere. It's better if they can see a warning at compile time that the class they use is stale.

The Javadoc class documentation for java.util.Stack as per Java SE 14 does come with this guidance:

A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations, which should be used in preference to this class. For example:

 Deque<Integer> stack = new ArrayDeque<Integer>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM