From previous example we have shown how to convert hex to decimal in Java. This section we will be showing ways to convert octal to decimal in java. We would be using the same approach as previous example. The static method parseInt of Integer class is flexible to handle any base number. The base number we are talking about is the radix input on this method. Similar to our previous example that we have used the radix 16, on this case we will be using base 8 since we are talking about octal base number.

Octal to decimal conversion in Java

This sample source code shows how to convert octal to decimal in java. The approach would be to take the string input from the console, and then parse it using the static method of Integer class parseInt(String input, radix). Finally we will be surrounding our statements with a try catch block in order for us to determine if any invalid input that comes from the user console.

Sample Output: java octal to decimal conversion