Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Byte
Byte is smallest integer data type Java supports. Range of byte data type is -128 to 127. Byte data type consumes 8 bits of memory.
Byte data type can be declared as follows.
byte <variable_name>;
Where variable_name is name of the identifier. You can also simultaneously declare and assign value to byte variable like given below.
byte b = 20;
Short
Next bigger integer type is short. Range of short variable is -32, 768 to 32,767. You can declare short variable as follows.
short <variable_name>;
Where variable_name is name of the identifier.
Short variables occupy 16 bits or two bytes of memory.
Int
Next bigger integer data type is int, which can hold values from -2,147,483,648 to 2,147,483,647.
You can declare int variable as follows.
int <variable_name>;
Where variable_name is name of the identifier. Int data type occupies 32 bits or four bytes of memory.
Long
The biggest integer data type in Java is Long. Long data type is used to store very big numbers and it takes 64 bits of memory.
Long variables can be declared as given below.
long <variable_name>;
or
long l = <value>;

iit should be better
Post new comment