如何在Java中使用带接口的模板

如何在Java中使用带接口的模板,java,templates,interface,Java,Templates,Interface,我正在用Java处理接口和模板。我有一个名为“problema”的接口,看起来像这样: public interface problema { boolean es_simple(problema P); solucion solucionar(problema P); problema[] dividir_problema(problema P); solucion combinar(problema P, solucion[] S);} public solucion solucionar

我正在用Java处理接口和模板。我有一个名为“problema”的接口,看起来像这样:

public interface problema {
boolean es_simple(problema P);
solucion solucionar(problema P);
problema[] dividir_problema(problema P);
solucion combinar(problema P, solucion[] S);}
public solucion solucionar(valormaximo P)
im使用的模板如下所示:

abstract public class Template implements problema{

public solucion resolver(problema P){
    problema[] PP;

    if(es_simple(P)){
        return solucionar(P);
    }
    else{
        PP=dividir_problema(P);
    }

    solucion[] SS=new solucion[PP.length];

    for(int i=0;i<PP.length;i++){
        SS[i]=resolver(PP[i]);
    }
    return combinar(P,SS);
}

//Metodos que implementaran las subclases
abstract public boolean es_simple(problema P);
abstract public solucion solucionar(problema P);
abstract public problema[] dividir_problema(problema P);
abstract public solucion combinar(problema P, solucion[] S);}
因此,我可以使用Java中名为p.Im new的对象valormaximo来实现这个方法,所以我不知道如何实现它,所以没有任何错误。顺便说一下,下面是valormaximo类的定义:

public class valormaximo implements problema
请你的问题而不是评论“模板”不存在于java中,因为它们在C++等其他语言中也存在。你所说的模板在我看来只是一个普通的抽象类。虽然我不能完全理解你到底想做什么,但听起来“泛型”应该是你应该查找的。