Priya Kathir
Priya Kathir

Reputation: 263

What does <?> mean in Android method signature?

I 'm going through a code and found the following method declaration.

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

What does <?> mean here?

Thank you.

Upvotes: 4

Views: 403

Answers (1)

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81684

AdapterView is a generic class. It takes another data type as a parameter, and its operation is then customized towards that type, in a way. Normally, you'll declare an AdapterView something like

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

This refers to an AdapterView customized for Strings.

Now, given all that: the <?> means that this method will accept an AdapterView regardless of the class it's customized for. It's a wildcard type specifier.

Upvotes: 6

Related Questions