-2

Can someone please explain to me what this expression in java means:

class BinaryNode<AnyType extends Comparable<? super AnyType>>

What does "AnyType extends Comparable" mean?

takendarkk
  • 3,178
  • 7
  • 23
  • 36
user3232446
  • 439
  • 2
  • 12
  • There's this thing called the Internet, see? And you can use it to [search for information](http://stackoverflow.com/questions/2827585/what-is-super-t-syntax). – MarsAtomic Nov 25 '14 at 00:01

1 Answers1

1

This declares a generic type parameter called AnyType. The rest of the declaration, extends Comparable<? super AnyType>, places an upper bound on what AnyType can be. Specifically, whatever AnyType is must be Comparable, and Comparable's type argument can be what AnyType is, or anything that is a superclass of that type. E.g. it could be Integer, because Integer is Comparable<Integer>. However, it could be some class that is Comparable<Object>, because Object is the superclass to all object types.

rgettman
  • 172,063
  • 28
  • 262
  • 343