Generics what does <?> actually mean?

generics, java

Solution

`<?>` is a shorthand for `<? extends Object>`, it's also known as an unbounded wildcard. So you can specify any type of object in your generic.

For example the `List` class is declared as `List<?>`, because it can be a list of anything you want.

Resources:

- Effective java - Generics.pdf

- Java language specification - Type Arguments and Wildcards

- oracle.com - Java tutorials, wildcards

Problem

Possible Duplicate: What does List<?> mean in java generics? What does the question mark in Java generics' type parameter mean? Apologies but it was difficult trying to search for `<?>`. What does mean in regards to Java generics? I understand `<A extends B>` and `<A super B>`, but I have never seen this question mark on its own before.

Original source

Related problems