Convert hexadecimal number to decimal number - Java Language Basics

Java examples for Language Basics:int

Description

Convert hexadecimal number to decimal number

Demo Code

 
public class Main {
 
        public static void main(String[] args) {
               /*from w w  w  .jav  a 2s  . c om*/
                //declare string containing hexadecimal number
                String strHexNumber = "20";
               
                int decimalNumber = Integer.parseInt(strHexNumber, 16);
                System.out.println("Hexadecimal number converted to decimal number");
                System.out.println("Decimal number is : " + decimalNumber);
               
        }
}

Result


Related Tutorials