An interface isn’t a class, but you could say that both interfaces and classes are types.
From the Java specification:
In the Java programming language, every variable and every expression has a type that can be determined at compile-time. The type may be a primitive type or a reference type. Reference types include class types and interface types.
Notice though there is a special class called Class<T>
that can represent both classes and interfaces:
Instances of the class Class represent classes and interfaces in a running Java application.
The fact that an interface is represented by a Class
instance where isInterface
is true
could give you the impression that an interface is just a special type of class. However this is not the case.