What does <?> Mean in the signature of an Android method?

I scan the code and find the following method declaration.

public void onItemClick(AdapterView<?> parent, View v, int position, long id) 

What does <?> Mean?

Thanks.

+4
source share
1 answer

AdapterView is a generic class. A different data type is required as a parameter, and its operation is then tuned to this type in some way. Usually you declare AdapterView something like

 AdapterView<String> avs = new AdapterView<String>(...); 

This applies to the AdapterView configured for String s.

Now, considering all this: <?> Means that this method will accept an AdapterView regardless of the class for which it is configured. This is a wildcard type specifier.

+6
source

Source: https://habr.com/ru/post/1385047/


All Articles