Reputation: 14258
I'm like to figure out which methods in an Interface has a default method.
For example, in java.util.Collection, stream()
has a default method. How would one go about programmatically finding that out
Upvotes: 0
Views: 49
Reputation: 198033
You can get all the methods from an interface from its Class<?>.getMethods()
: myInterface.getMethods()
.
Each of those Method
objects has a function isDefault()
: thisMethod.isDefault()
.
Upvotes: 4