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

java - IandI - Implementing the Relatable Interface description

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6-pool
    • docs
    • generic
    • generic

      http://download.oracle.com/javase/tutorial/java/IandI/usinginterface.html
      The example given in section 'Implementing the Relatable Interface' doesn't suggest a good design and might confuse beginner programmers, in my opinion:

      As RectanglePlus implements the Relatable interface, I would expect that I can pass any kind of Relatable instances in the isLargerThan method, however, I would encounter an ugly big exception if I tried it with objects other than RectanglePlus (or its subclasses).
      Hard coding exact types in an interface implementation questions the whole point of using an interface.

            Unassigned Unassigned
            skannan Sowmya Kannan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: