A class is a type. An interface is a type. A primitive is a type. An array is a type.
Therefore, every type is also either a class (including an enum constant), an interface, a primitive, or an array.
There are two distinct categories of types: primitive types and reference types:
- A variable of primitive type always holds a primitive value of that same type. Such a value can only be changed by assignment operations on that variable.
- A variable of reference type always holds the value of a reference to an object. All objects, including arrays, support the methods of class
Object
. The reference types are class types (including enum types), interface types, and array types.
Every piece of data has a type which defines its structure, namely how much memory it takes up, how it is laid out, and more importantly, how you can interact with it.
Examples of primitive types:
int
float
char
boolean
Examples of class types:
Examples of interface types:
Examples of array types:
int[]
String[]
Integer[][][]
Basically, anything that you can refer to as a variable has a type, and classes are a kind of a type.
More info here: http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html