Home / Programs / int Datatype in Java
Programming Example

int Datatype in Java

👁 2,720 Views
💻 Practical Program
📘 Step by Step Learning
int Datatype in Java

Information & Algorithm

  • Int data type is a 32-bit signed two's complement integer.

  • Minimum value is - 2,147,483,648 (-2^31)

  • Maximum value is 2,147,483,647(inclusive) (2^31 -1)

  • Integer is generally used as the default data type for integral values unless there is a concern about memory.

  • The default value is 0

  • Example: int a = 100000, int b = -200000

Program Code

 public class IntDataType {

   public static void main(String []args) {
      // this is declaration and initialization of variable a
	  // datatype is int
	  int a = 10000;
	  // this is declaration and initialization of variable b
	  // datatype is int
      int b = -5000;
      System.out.println(a); // it will print a variable
      System.out.println(b); // it will print b variable
   }
}

  

Output

10000
-5000
Press any key to continue . . .

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.