I have a two part question
My book states this "If the wildcard is specified without an upper bound, then only the methods of type Object can be invoked on the values of the wildcard type"
I have no idea what this could mean. What does this mean?
Also what are the limitations place on wild card types (unbounded and bounded)? For instance if I have a reference to MyClass<?>
or MyClass<? extends SomeOtherClass>
, what methods am I not allowed to call through that reference. I don't understand what the wild card allows or disallows me to do, which is probably why I don't understand the quote from the book.
I have an example for the second part:
class SomeOtherClass
{
[...]
}
class MyClass<T>
{
[...]
}
class Test
{
public static void main(String[] arg)
{
MyClass<? extends SomeOtherClass> myClass = new MyClass<String>() // for instance what does the wild card reference limit me to in any way. In a general sence.
}
}