I have the following classes (see below). How can I put one generic type into another generic?
class MySet<T> extends MyCollection<T>{}
class MyList<T> extends MyCollection<T>{}
class MyCollection<T> {}
// It works but MyCollection has no type
class MyProvider<C extends MyCollection> {}
// It does not work. What is the correct way here?
class MyProvider<C extends MyCollection<T>> {}
You have to define second generic type first, Then use it in nested generic class:
//Define T as second generic type
class MyProvider<T,C extends MyCollection<T>> {}
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.