I am trying to instantiate
LinkedList<?> op = new LinkedList<?>();
But I get error
Cannot instantiate the type LinkedList<?>
Why is it that this cannot be instantiated in Java?
If you don't know what object type will be inside the list, why are you using generics?
It's been a long time since I programmed in Java but my understanding is that wildcard generics are made to match something, e.g. when you are declaring a method parameter, you can use a wildcard so that different generics can be passed to it. Also, a variable can use a wildcard to accept different generic types.
However, when creating an instance, you have to supply a specific type. The wildcard just doesn't have any sense there.
Are all possible but