We can convert octal to decimal in java using Integer.parseInt() method or custom logic.
Java Octal to Decimal conversion: Integer.parseInt()
The Integer.parseInt() method converts a string to an int with the given radix. If you pass 8 as a radix, it converts an octal string into decimal. Let us see the signature of parseInt() method:
public static int parseInt(String s,int radix)
Let's see the simple example of converting octal to decimal in java.
Output:
Let's see another example of Integer.parseInt() method.
Output:
Java Octal to Decimal conversion: Custom Logic
We can convert octal to decimal in java using custom logic.
Output: