Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • #3 is just ordinary contravariance. You up the type parameter of the return type to the most specific common super type; for two "totally unrelated" classes the most specific common super type is Object. Commented Aug 30, 2014 at 20:34
  • the compiled code would be the same Commented Aug 30, 2014 at 20:46
  • 1
    If both Car and Train both implement interfaces Vehicle and PurchasableItem, which type would a concatenation of cars and trains become? Commented Aug 30, 2014 at 21:08
  • 1
    @PeteKirkham <T extends Vehicle & PurchasableItem>, but Java is quite limited in how this can be used. Commented Aug 30, 2014 at 21:20
  • 1
    @Pete, probably in that situation the compiler would flag an ambiguity and require the programmer to explicitly specify the result type. Commented Aug 30, 2014 at 21:50