2014-03-05

Java's Types: Primitives vs Reference Types

In Java there are essentially two different kinds of types. The primitive type denotes non-nullable types like boolean, byte, sbyte, short, integer, float, and double. The reference type denotes all nullable types, typically known as "objects" which always have "Object" as their explicit or implicit super class, e.g. Integer, Double, YourVeryOwnBusinessObject, BusinessDao, PersonDto, RuntimeException, or Exception.

Actually null is a literal of the "null" type which has no name but can be assigned or cast to any reference type. However it cannot be assigned to primitive types. By default all reference types are initialized with null.