Lecture 5-DataTypes
Lecture 5-DataTypes
Valid types are byte, short, int and long. Which type you should use, depends on the
numeric value.
Floating point types represents numbers with a fractional part, containing one or more
decimals. There are two types: float and double.
Non-Primitive Data Types
Non-primitive data types are called reference types because they refer to
objects.
The main difference between primitive and non-primitive data types are:
•Primitive types are predefined (already defined) in Java. Non-primitive types are
created by the programmer and is not defined by Java (except for String).
•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.