通用java接口

通用java接口,java,generics,interface,Java,Generics,Interface,我不熟悉泛型。我想为许多水果类编写一个接口SearchableFruit,如: public interface SearchableFruit<T>{ //returns a list of newer fruit object than current fruit object public static List<T> searchNewerFruit(T curr); } 我以前从未做过接口,这对我来说不起作用,你能澄清我应该如何正确编写它吗

我不熟悉泛型。我想为许多水果类编写一个接口SearchableFruit,如:

public interface SearchableFruit<T>{
    //returns a list of newer fruit object than current fruit object
    public static List<T> searchNewerFruit(T curr); 
}
我以前从未做过接口,这对我来说不起作用,你能澄清我应该如何正确编写它吗

有什么建议吗?
谢谢

首先,接口不能包含静态方法。 第二,在实现中没有输入。正确:

public class Apple implements SearchableFruit<Apple>{
    public List<Apple> searchNewerFruit(Apple currentApple){
    //TODO get apples newers than currentApple
    //return a list of Apples
}

}
应该是这样的

public interface SearchableFruit<T>{
    public List<T> searchNewerFruit(T curr); 
}

public class Apple implements SearchableFruit<Apple> {
    public List<Apple> searchNewerFruit(Apple currentApple){
        // impl
    }
}

问题是什么?可能重复:注意:接口不能有静态方法。Apple实现的公共类SearchableFructure必须具体说明您想要什么样的建议!ctrl+c ctrl+v模式。。。电子。。。
public interface SearchableFruit<T>{
    public List<T> searchNewerFruit(T curr); 
}

public class Apple implements SearchableFruit<Apple> {
    public List<Apple> searchNewerFruit(Apple currentApple){
        // impl
    }
}