Int Data Type in Java

 
The int data type represents a 32-bit signed two’s complement integer. It has a minimum value of -231 and a maximum value of 231-1.

Program to declare and use Java primitive int variable.

/**
 * Program to declare and use Java primitive int variable.
 * @author javawithease
 */
public class DataTypeIntExample {	
  public static void main(String args[]){ 
	//Declare int type variables.
	int i1 = 10;
	int i2 = 20;
 
        //Print variables value.
        System.out.println("i1 Value: " + i1);
        System.out.println("i2 Value: " + i2);
 
        //Print Sum i1 and i2.
        System.out.print("Sum: ");
        System.out.println(i1 + i2);
  }
}

Output:

i1 Value: 10
i2 Value: 20
Sum: 30

Download this example.