Reputation: 2428
I'm trying to declare an object which must implement a specific interface. I thought the following would work in Java as it does in some other languages but I'm at a loss here:
Class<? implements **theInterface**> implementingObject
Any pointers would be appreciated
Upvotes: 0
Views: 742
Reputation: 40058
What you are declaring here isn't an object that implements an interface, but a class of an object which implements that interface. An object implementing an interface is simply declared as the interface type, i.e.
theInterface implementingObject;
Upvotes: 1
Reputation: 53694
for generics, you use "extends" regardless of whether it is a Class or Interface.
Class<? extends **theInterface**> implementingObject
Upvotes: 7