Craig Millard Craig Millard - 4 months ago 7x
Java Question

Java syntax with greater than/less than: <> are they class specific?

I've been doing an Android tutorial and encountered a class with the following:

public class ImageAndTextAdapter extends ArrayAdapter<String> {

Is the
a form of inheritance by type? Or is it some other Java syntax that I should know about?

The class is:



This is called generics. The class within < and > is a type parameter.

This is easiest explained by an example:

An ArrayList can store items. If you specify a type parameter like this: ArrayList<String> then this array list will store items of String type only, (in other words, it will store Strings only)!

Similarly, the ArrayAdapter is "parameterized" by a type as well. The ArrayAdapter probably holds a value, and this value will be of the type specified between < and >, which in your case is String.

Useful links: