Should the documentation state peekFirst() as equivalent to Stack's peek()?

Chen Liang chen.l.liang at oracle.com
Thu Jul 25 11:57:17 UTC 2024


Hi Turkhan, this mail belongs to core-libs-dev list. I have forwarded your mail to the right list.

Indeed, we should claim that peek() is equivalent to peekFirst(); the information in stack section should be a typo, as peek() being the same as peekFirst() is claimed by the deque section and the peek() specification.

I have created a ticket on the Java Bug System to track this issue: [JDK-8337205] Typo in Stack vs Deque Method table in Deque specification - Java Bug System (openjdk.org)<https://bugs.openjdk.org/browse/JDK-8337205>

Feel free to open a pull request to jdk to fix this bug.

Best, Chen Liang
________________________________
From: jdk-dev <jdk-dev-retn at openjdk.org> on behalf of Turkhan Badalov <badalov.turxan at gmail.com>
Sent: Thursday, July 25, 2024 4:58 AM
To: jdk-dev at openjdk.org <jdk-dev at openjdk.org>
Subject: Should the documentation state peekFirst() as equivalent to Stack's peek()?

Here is the table "Comparison of Stack and Deque methods" that lists equivalent Deque methods compared to Stack methods: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Deque.html

At the moment, getFirst() is said to be equivalent to peek(). Since peek() doesn't throw an exception when the queue/stack is empty, peekFirst() could be a better equivalent because getFirst() throws.

In fact, the documentation of the peek() method itself says that this method is equivalent to peekFirst(): https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Deque.html#peek().

If this should be posted somewhere else, please let me know. I am still new to using mailing lists. Cheers.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240725/54072215/attachment-0001.htm>


More information about the core-libs-dev mailing list