Reputation: 7540
I have got a similar line digging up a OpenSource Project:
abstract class AbstractClass<A extends ParentClass1,
B extends ParentClass2>
Can you please tell me what actually it means? I think java does not support multiple inheritance so what actually we are doing here? And what is A
and B
here? :S
Upvotes: 2
Views: 1906
Reputation: 17622
If you remove the content within <>
, then you see its only
abstract class AbstractClass
that means, the class is not extending any classes at all.
abstract class AbstractClass<A extends ParentClass1,
B extends ParentClass2>
essentially means, the class would like to declare 2 generics A and B, and force its type. That means, it want the implementer of the class to supply the 2 classes which extends ParentClass1
and ParentClass2
respectively.
Please see this for more clarification
Upvotes: 0
Reputation: 73
it's generic type look here for generics: http://docs.oracle.com/javase/tutorial/java/generics/types.html
Upvotes: 0
Reputation: 7804
Here A and B are just place holders which can be replaced with any class that extends ParentClass1 and ParentClass2 respectively. You can pass arguments in angular brakets(<>) when you create object of this class. These arguments will be substituted for A and B by the compiler during compilation.
The above code does not indicate multiple inheritance. Please read generics in detail to understand this.
Upvotes: 2