Integer Data Type : Java Programming Language

Integer Data Type :

  1. Integer Data Type is used to store integer value.
  2. Integer Data Type is Primitive Data Type in Java Programming Language.
  3. Integer Data Type have respective Wrapper Class - “Integer“.
  4. 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

Class IntDemo
{
public static void main(String args[])
  {
  int number=0;
  System.out.println("Total Number : " + number);
  }
}

Explanation :

  1. Primitive Variable can be declared using “int” keyword.
  2. Though Integer contain default Initial Value as 0 , still we have assign 0 to show assignment in Java.
  3. “+” operator is used to concatenate 2 strings.
  4. Integer is converted into String internally and then two strings are concatenated.

Integer Literal in Java :

  1. Value Stored in the Integer Variable is called as Literal.
  2. 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)
Hexadecimal Number 0×25
Octal Number 025 (Preceding 0)