data type in Java

The main difference between primitive and non-primitive data types are:
* Primitive types are predefined in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String).
* Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.
* A primitive type has always a value, while non-primitive types can be null.
* A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter.
* The size of a primitive type depends on the data type, while non-primitive types have all the same size.

The eight primitive data types in Java are:
* boolean
* char
* floating-point: float, double
* integer: includes byte, short, int, long

Fields that are declared but not initialised will be set to a reasonable default by the compiler. Local variables are slightly different; the compiler never assigns a default value to an uninitialised local variable. If you cannot initialise your local variable where it is declared, make sure to assign it a value before you attempt to use it. Accessing an uninitialised local variable will result in a compile-time error.