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.
Range: -2147483648 to 2147483647
Program to declare and use Java primitive int variable.
public class DataTypeIntExample { public static void main(String args[]){ //Declare int type variables. int i1 = 100; int i2 = 200; //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: 100 i2 Value: 200 Sum: 300