In this section, we are going to learn to convert a numeric string type Object into a primitive type int and Integer Object to primitive type int.
Convert Object to Int
In this section, we are going to learn to convert a numeric string type Object into a primitive type int and Integer Object to primitive type int. .
Code Description:
The following program converts numeric string type object into primitive type int and Integer type object to primitive type int. The parseInt() method of an Integer class takes a numeric string object and returns the primitive type int value. Again, this program converts an Integer object into a primitive type int using the intValue() method.
Here is the code of this program:
import java.io.*;
|
Output of this program
C:\vinod>javac ObjectToInt.java C:\vinod>java ObjectToInt Numeric string to primitive int = 123 Integer object ot primitive int = 123 C:\vinod> |