Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Fruit {...}
  2. class Apple extends Fruit implements Comparable<Apple> {...}
  3. // apples are only comparable to apples
  4.  
  5. class Fruit implements Comparable<Fruit> {...}
  6. class Apple extends Fruit {...}
  7. // comparable to any fruit or subclass
  8.  
  9. //to accommodate the second example:
  10. <T extends Comparable<? super T>> T max(Collection<? extends T> coll)
  11. // the type parameter is read as: my type is a subtype of a Comparable that takes in and return a type that is a supertype to T
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement