0

Possible Duplicate:
Java Generics Wildcarding With Multiple Classes

I was reading an Android app's source code and I came across a grammar problem. Being a Java newbie, I've no idea what one specific part actually means. The code looks like.

public abstract class TabPagerActivity<V extends PagerAdapter & FragmentProvider>
        extends PagerActivity implements OnTabChangeListener, TabContentFactory {

What I feel confused about is this part:

<V extends PagerAdapter & FragmentProvider>
Community
  • 1
  • 1
Di Wu
  • 6,436
  • 3
  • 35
  • 51

1 Answers1

3

That syntax describes the requirement that V will be assignable to both PagerAdapter and FragmentProvider, allowing the programmer to specify multiple interfaces as a requirement for a type match. Since Java does not support multiple inheritance directly, at least one of those types will normally be an interface, unless redundant information is present in the form of both a parent class and a subclass being specified.

You can find more information on multiple bounds for Java generics in the corresponding tutorial.

thkala
  • 84,049
  • 23
  • 157
  • 201