Lecture 5
Lecture 5
Data types
Types of data types
Primitive data types
Non primitive data types
Syntax for declaring variables
Declaration of variable example
Giving value to variable
Data types
Data types in Java are of different sizes
and values that can be stored in the
variable that is made as per convenience
and circumstances to cover up all test
cases. Java has two categories in which
data types are segregated
Primitive Data Type: such as Boolean,
char, int, short, byte, long, float, and double
Non-Primitive Data Type or Object
Data type: such as String, Array, etc.
type Description Default Size Example Literals Range of values
twos-complement
byte 0 8 bits (none) -128 to 127
integer
characters
‘a’, ‘\u0041’, ‘\101’, representation of
char Unicode character \u0000 16 bits
‘\\’, ‘\’, ‘\n’, ‘β’ ASCII values
0 to 255
twos-complement
short 0 16 bits (none) -32,768 to 32,767
integer
-2,147,483,648
twos-complement
int 0 32 bits -2,-1,0,1,2 to
intger
2,147,483,647
-
9,223,372,036,854,77
twos-complement 5,808
long 0 64 bits -2L,-1L,0L,1L,2L
integer to
9,223,372,036,854,77
5,807
TO BE CONTINUE……