开发者

Problem with Java generic interface

Is People in the following Java snippet a type name (like T or K) or a concrete class (or interface) name?

public class Student implements Comparable<People> { ... }

And where can I find explanation or specifica开发者_Python百科tion on such issue?


In this context, People is the name of a concrete class, not a type variable. If you wanted it to be a type variable, you'd have to say that Student itself is a generic:

public class Student<People> implements Comparable<People> { ... }

By the way, notationally, wildcards like T and K that are stand-ins for classes are usually called type variables rather than types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜