Integer Data Type :
- Integer Data Type is used to store integer value.
- Integer Data Type is Primitive Data Type in Java Programming Language.
- Integer Data Type have respective Wrapper Class – “Integer“.
- Integer Data Type is able to store both unsigned ans signed integer values so Java opted signed,unsigned concept of C/C++.
Integer Data Type Can have 4 types of Values these are listed below table -
| Name|| Width|| Range|
| long|| 64|| –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807|
| int|| 32|| –2,147,483,648 to 2,147,483,647|
| short|| 16|| –32,768 to 32,767|
| byte|| 8|| –128 to 127|
Live Example : Declaring Integer Variable in Java Programming
public static void main(String args)
System.out.println("Total Number : " + number);
- Primitive Variable can be declared using “int” keyword.
- Though Integer contain default Initial Value as 0 , still we have assign 0 to show assignment in Java.
- “+” operator is used to concatenate 2 strings.
- Integer is converted into String internally and then two strings are concatenated.
Integer Literal in Java :
- Value Stored in the Integer Variable is called as Literal.
- In the above example 0 is integer literal.
|Type of Value to be stored||Convention|
|Integer||Any Valid Integer Value|
|Long||10L (L at the end)|
|Octal Number||025 (Preceding 0)|