SwiftMango
SwiftMango

Reputation: 15304

Java: how to create a generic class that requires a data type which extends a class and implements an interface?

I want to create a composite in GWT that require a class which extends a class and implements an interface. Psudo code as below (it does not work apparently):

class GridRow<T extends Widget implements HasText> extends Composite{
  //more codes here
}

Upvotes: 4

Views: 289

Answers (1)

Frank Pavageau
Frank Pavageau

Reputation: 11735

That's written as:

class GridRow<T extends Widget & HasText> extends Composite {
    // ...
}

You can have [class or interface]( & [interface])* (in pseudo regex language).

Upvotes: 13

Related Questions