java - IandI - Implementing the Relatable Interface description

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 6-pool
    • Component/s: 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.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: