我正在学习代码。我找到了这两个班。我不明白他们是如何相关的。表达式“T延伸PieceType”是什么意思,T代表什么?Java-接口使用接口
piece.java:
public interface Piece<T extends PieceType> {
/**
* Returns the color.
* @return the color
*/
PieceColor getColor();
/**
* Returns the type.
* @return the type
*/
T getType();
}
pieceType.java:
public interface PieceType {
/**
* Returns the type's base rating.
* @return the base rating within range [0, 1000]
*/
double getRating();
}
您需要阅读有关泛型。开始[这里](http://docs.oracle.com/javase/tutorial/java/generics/)。 –
消化后,转到[这里](http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html)。 –