The type is not knowable at compile time, for type ?
. We use ?
when the method does not depend on the type. Because the add
method depends on the type, ?
is not a good fit for this.
The Java compiler will attempt to find a method signature that matches the method name, the number and type of the arguments provided. So let's do the same with yours.
name: add
number of arguments: 1
type: ? // Your issue.
However, NavigableSet
does not have a method that matches this criteria, hence why no method is found.