How to use multiple upper bounds in generics

前端 未结 1 1550
庸人自扰
庸人自扰 2021-01-13 02:35

I have a Interface Foo which has a generic type -

 public interface Foo {  
     boolean apply(T t);  
 }

Having another class Ba

相关标签:
1条回答
  • 2021-01-13 03:21

    Wouldn't this work?

    public class Bar<T extends A & B> implements Foo<Collection<T>>{
      @Override
      public boolean apply(Collection<T> collect){
       ...
      }  
    }
    
    0 讨论(0)
提交回复
热议问题