The problem with the Java interface

Is the People in the following Java fragment a type name (e.g. T or K ) or a specific class name (or interface)?

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

And where can I find an explanation or specification on such a problem?

+4
source share
1 answer

In this context, People is the name of a particular class, not a type variable. If you want this to be a type variable, you must say that Student itself is generic:

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

By the way, conditionally wildcards such as T and K , which are stand-ins for classes, are usually called type variables, not types.

+11
source

Source: https://habr.com/ru/post/1335176/


All Articles