Home » Java Convert Octal to Decimal

Java Convert Octal to Decimal

by Online Tutorials Library

Java Convert Octal to Decimal

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:

Let’s see the simple example of converting octal to decimal in java.

Test it Now

Output:

81 

Let’s see another example of Integer.parseInt() method.

Test it Now

Output:

81 19 8 

Java Octal to Decimal conversion: Custom Logic

We can convert octal to decimal in java using custom logic.

Test it Now

Output:

Decimal of 121 is: 81 Decimal of 23: 19 Decimal of 10 is: 8 

References

  1. Integer.parseInt() JavaDoc
  2. Integer.parseInt() TutorAspire

You may also like