Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Java generic interface

Tags:

java

generics

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?

like image 995
象嘉道 Avatar asked Dec 21 '22 19:12

象嘉道


1 Answers

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.

like image 65
templatetypedef Avatar answered Jan 08 '23 01:01

templatetypedef