Data TYpes
Data TYpes
• These data types act as the basic building blocks of data manipulation in
Java. Primitive data types have a constraint that they can hold data of
the same type and have a fixed size. Primitive data types are also called
intrinsic data types. We can also perform operations on primitive data
types.
Data Types
Data Types
• Java Characters
• A character is used to store a ‘single’ character. A single quote must
surround a character. The valid Character type is char. In Java, a character is
not an 8-bit quantity but here character is represented by a 16-bit Unicode.
• Syntax:
• Default Value:
• ‘\u0000’ (0)
• Range:
• 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).
• 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.
• Examples of non-primitive types are Strings, Arrays, Classes, Interface, etc.
Operators