WIZARDELF
WIZARDELF

Reputation: 3895

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 specification on such issue?

Upvotes: 4

Views: 139

Answers (1)

templatetypedef
templatetypedef

Reputation: 373402

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.

Upvotes: 11

Related Questions