I am studying now Reflection. In the example there is a string
Class<?> cls1 = Integer.class; What does the question mark mean?
And why not just write
Class cls1 = Integer.class; I am studying now Reflection. In the example there is a string
Class<?> cls1 = Integer.class; What does the question mark mean?
And why not just write
Class cls1 = Integer.class; Grundy is right.
In theory, it can be useful in three cases.
Object then when initializing the new List<Integer> will be an error, and with <?> You can initialize this variable both as new List<Integer> and as new List<String> .<? super Object> <? super Object> , <? extends Numeric> <? extends Numeric> and initialize with any class that fits these criteria, and not just specifically with this interface or class (A sort of double filtering).Source: https://ru.stackoverflow.com/questions/509337/
All Articles
<?>Is an outdated syntax and just a bad form. - Pavel Mayorov