简体   繁体   中英

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
}

That's written as:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM