Java Byte intValue() method
The intValue() method of Java Integer class returns an int value for this Integer. Syntax public int intValue() Parameters NA Specified by This method is specified by intValue in class Number Return Value This method returns the numeric value of this object after conversion to type int. Example 1
public class JavaIntegerIntValueExample1 { public static void main(String[] args) { Integer a=456; //returns primitive int value for Integer a int val=a.intValue(); System.out.println("int value "+a+" : "+val); } }Output
int value 456 : 456Example 2
public class JavaIntegerIntValueExample2 { public static void main(String[] args) { int a=456; //Here, a is the primitive type object it cannot be used to call Integer class methods int val=a.intValue(); System.out.println("int value "+a+" : "+val); } }Output
Error:(7, 18) java: int cannot be dereferenced