Question Mark inside Angled Brackets in Java?

Edit: Thanks to Jon Ellis for some clarification.

Edit 2: Added more context to the code.

Edit 3: Thanks again to Jon for more clarification.

I came across something like this while following an android tutorial:

import android.widget.AdapterView.OnItemClickListener;

public class HelloLinear extends Activity
  public void onCreate(Bundle savedInstanceState)
      new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
          Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();

If you look at the line with the colours, what the hell does that mean?

A quick Google search led me to a tutorial on Generics in Java.  Turns out the question mark is called a wild card. I am not entirely sure on the full meaning of that line as my goal is to get just enough information to carry on with the tutorial. So having said that, what I think it is saying is: The onItemClick() takes as it’s first parameter a construct of AdapterView of an unspecified type. The collection can referenced using the variable name parent.

The reason I added more context because I kept staring at this code as there was something else that was not sitting correctly with me. Look at this my original understanding (because I was applying dynamic type rules from JavaScript) was It was a class definition (HelloLinear) containing a function definition, containing a function call which instantiates and maybe even possibly defines an OnItemClickListner class, which then defines a function.

Turns out I was way off. What is actually happening is we are defining a HelloLinear class which defines the onCreate() function which calls the gridview member function which takes as a parameter, I think, any object that implements the ALREADY defined OnItemClickListener interface (which I should have seen from the imports) which is required to implement the onItemClick function. I guess what I was struggling with is that I was not aware you could firstly, instantiate an interface… or secondly instantiate an interface AND define a function inline. Or was it you could instantiate interfaces and it’s the abstract class you can’t instantiate? Or is that just a java thing?

Turns out the new keyword is used slightly differently to what I am used to. The new keyword here is defining an “Anonymous Inner Class” that implements the OnItemClickListener interface.