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?
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?
Copyright © 2021 Jogjafile Inc.
This declares a generic type parameter called
AnyType. The rest of the declaration,extends Comparable<? super AnyType>, places an upper bound on whatAnyTypecan be. Specifically, whateverAnyTypeis must beComparable, andComparable's type argument can be whatAnyTypeis, or anything that is a superclass of that type. E.g. it could beInteger, becauseIntegerisComparable<Integer>. However, it could be some class that isComparable<Object>, becauseObjectis the superclass to all object types.