Gene是最上层的接口,代码来源于国外的java遗传算法的jentics库。
其中A是类型,关键是 G extends Gene,看不懂
public interface Gene>
extends Factory, Serializable, ValueType, Verifiable
{
/**
* Return the allel of this gene.
*
* @return the allel of this gene.
*/
public A getAllele();
}
泛型在是编译期间编译器检查 你写的代码是否符合规范
比如我实现Gene
class GeneImpl> implements Gene{
public GeneImpl(A a,G g){
}
@Override
public Object getAllele() {
// TODO Auto-generated method stub
return null;
}
}
在new GeneImpl(xx,yy )是会检查你传入的参数是否合法,
xx是否是A类型;yy是否是Gene或其子类型