Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

gwt

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
}
like image 718
SwiftMango Avatar asked Dec 12 '22 22:12

SwiftMango


1 Answers

That's written as:

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

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

like image 161
Frank Pavageau Avatar answered Jan 19 '23 00:01

Frank Pavageau