# Convert Hexadecimal number into Integer

In this section, you will learn to convert hexadecimal data into integer.

Tutorials

# Convert Hexadecimal number into Integer

In this section, you will learn to convert hexadecimal data into integer. The java.lang package provides the functionally to convert the hexadecimal data into an integer type data.

Code Description:

The following program takes an integer type data at the console (using the keyboard) and converts the hexadecimal data into an integer type data using valueOf() method. It take a number as a string. It converts the number into an integer data using the Integer.valueOf() method.

Integer.valueOf() :The Integer.valueOf() returns an integer object containing  the value extracted from the specified String. The result is an integer that represents the integer value specified by the string .

Here is full code of this program:

 ``` import java.io.*; import java.lang.*; public class  HexaToInteger{   public static void main(String[] args) throws IOException{   BufferedReader read =    new BufferedReader(new InputStreamReader(System.in));   System.out.println("Enter the hexadecimal value:!");   String s = read.readLine();   int i = Integer.valueOf(s, 16).intValue();   System.out.println("Integer:=" + i);   } }```

Output of this program.

 C:\corejava>java HexaToInteger Enter the hexadecimal value:! 24 Integer:=36 C:\corejava>

# Convert Hexadecimal number into Integer

Related Tutorials

Subject (*):

haseeb khan
June 14, 2011
gota soveld problamo

i think its very clear idea that i got thanks to you who get solved this problem
sandeep
June 15, 2011
c++

enter an integer number from the user and convert it into hexadecimal
Rizan
August 18, 2011
will not work

It will not work for a hexa decimal value which contians alphabets eg: E34F2