Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8200728

Docs (Comparison of Stack and Deque methods) for Deque is not correct

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      There is a table in the front part about Comparison of Stack and Deque methods.

      It is stated that the Stack method peek() is equivalent to the Deque method peekFirst(). However, it is not. The Stack's method peek() will throw EmptyStackException if the stack is empty. However, Deque's method peekFirst() will return null if this deque is empty.

      I think Stack method peek() is equivalent to the Deque method getFirst(), where it will throw NoSuchElementException if this deque is empty. Even though these two exceptions are not same, at least it is not totally different behaviour.

      This docs remains same for Java SE7, 8 and 9:
      https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html
      https://docs.oracle.com/javase/8/docs/api/java/util/Deque.html
      https://docs.oracle.com/javase/9/docs/api/java/util/Deque.html


      URL OF FAULTY DOCUMENTATION :
      https://docs.oracle.com/javase/8/docs/api/java/util/Deque.html

        Attachments

          Activity

            People

            Assignee:
            martin Martin Buchholz
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: