Data Types
Data Type Size Default Value Description
Integer values (-128
byte 1 byte 0
to 127)
Integer values (-
short 2 bytes 0
32,768 to 32,767)
int 4 bytes 0 Integer values
long 8 bytes 0L Large integer values
Floating-point
float 4 bytes 0.0f
numbers
Larger floating-
double 8 bytes 0.0d
point numbers
Single character
char 2 bytes '\u0000'
(Unicode)
boolean 1 byte false True or false values
Integer
• Integer Types
• byte: 1 byte, -128 to 127
• short: 2 bytes, -32,768 to 32,767
• int: 4 bytes, -2^31 to 2^31-1
• long: 8 bytes, -2^63 to 2^63-1
Floating-Point
• Floating-Point Types
• float: 4 bytes, 32-bit precision
• double: 8 bytes, 64-bit
• precisionPrecision and range differences
Character Type
• Character Type
• char: 2 bytes, represents a single Unicode
character
• Example: 'A', '1', '%'
Boolean
• Boolean Type
• boolean: Represents true or false
• Size and storage considerations
• Usage in control flow and logic operations
Reference Data Types
• Reference Data Types:
• Objects that reference data (arrays, classes,
interfaces)
• Examples: Strings, arrays, custom objects
String
• String Data Type
• String is an object, not a primitive
• Immutable sequence of characters
• String manipulation methods:
• .length(), .substring(), .charAt()
Arrays
• Arrays
• Arrays are reference types
• Fixed size and stores multiple values of the
same type
• Example: int[] numbers = new int[5];