Reputation: 2319
If a method is declared in an interface (implemented by many classes), how to know at runtime which implementation this method uses.
Upvotes: 0
Views: 75
Reputation: 21866
Assuming that's a hypothetical question, you can use getClass()
method on the instance to get the concrete type of the implementing class.
But you probably should usually refrain from doing so. The whole idea of an interface is to abstract its implementation.
Upvotes: 3