Java- Interface makes use of an interface -
i'm studying code. 've found these 2 classes. don't understand how related. expression "t extends piecetype" mean, t stand for?
piece.java:
public interface piece<t extends piecetype> { /** * returns color. * @return color */ piececolor getcolor(); /** * returns type. * @return type */ t gettype(); }
piecetype.java:
public interface piecetype { /** * returns type's base rating. * @return base rating within range [0, 1000] */ double getrating(); }
as mentioned, means type, t, pass piece must extend piecetype.
here have interface extends piecetype:
public interface newpiece extends piecetype { ... }
you instantiate piece object doing this:
piece<newpiece> apiece = new someimplementationofpiece<newpiece>();
because newpiece extends piecetype given in definition:
public interface piece<t extends piecetype> { ... }
Comments
Post a Comment