Home   |   About   |   Terms   |   Contact    
Read & Learn
 

Integer data types in Java?

Java

☯ All Java Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding Integer data types in Java?
Last updated on: .



◕ Integer data types

- In Java we can store Integer with the help of four different types of variables.

These are:
* byte
* short
* int
* long

All of these four are signed variables, means they can store both negative and positive values.
These four integer type can store different length of integer values.
The details are given bellow:

byte
This type occupy 1 byte ( 8 bits ) of memory.
This type can store values from -128 to +127.
Example of statement:
byte ourArea;

short
This type occupy 2 bytes ( 16 bits ) of memory.
This type can store values from -32768 to +32767.
Example of statement:
short ourState;

int
This type occupy 4 bytes ( 32 bits ) of memory.
This type can store values from -2147483648 to +2147483647.
Example of statement:
int country;

long
This type occupy 8 bytes ( 64 bits ) of memory.
This type can store values from -9223372036854775808 to +9223372036854775807.
Example of statement:
long earth;

In normal practice we mostly use the type int or long among the four.



Related Java articles:
What is Java? Where we can apply Java?
Why Java is a Machine Independent Program? What is Machine Independent Program?
Root Directory of Java
How to Compile and run a Java Program?
What is variable in a program?
What is identifier in Java?





Popular Google Pages:





Top of the page

Amazon & Flipkart Special Products

   


Top of the page