convert integer into decimal in java code example
Example 1: Java convert hex to decimal
public class ConvertHexToDecimal
{
public static void main(String[] args)
{
String strHex = "b";
int decimal = Integer.parseInt(strHex, 16);
System.out.println("Decimal number : " + decimal);
}
}
Example 2: Java convert octal to decimal
public class OctalToDecimalDemo
{
public static void main(String[] args)
{
String strOctal = "141";
int decimal = Integer.parseInt(strOctal, 8);
System.out.println(decimal);
}
}