# Convert Octal to Decimal

In this section, you will learn to convert an octal number to decimal. The following program helps you converts number octal to decimal.

Tutorials

# Convert Octal to Decimal

In this section, you will learn to convert an octal number to decimal. The following program helps you converts number octal to decimal.

Description of code:

This program takes an octal number at console converts it into decimal number using parseInt() method. This method parses the string value as a signed integer in the radix specified by the second argument as 8. And you get the decimal number.

Integer.parseInt(oct, 8): This method takes an int value in a string format and it returns an Integer object. It converts an octal number into decimal and takes two parameters. First argument passed is a specified String which is  parsed using the radix given through the second argument. The first parameter interprets as representing a signed integer in the radix specified by the second parameter.

Use Keyboard  as :S- This is a string to be parsed.
Radix (as a use integer value):- The radix represents an integer value to be parsed in the interpreting string.

Here is the code of this program:

 ``` import java.io.*; import java.lang.*; public class  OctalToDecimal{   public static void main(String[] args)throws IOException{   BufferedReader reader =    new BufferedReader(new InputStreamReader(System.in));   System.out.println("Enter the octal number:");   String oct = reader.readLine();   int i= Integer.parseInt(oct,8);   System.out.println("Decimal:=" + i);   } }```

Output of this program:

 C:\corejava>java OctalToDecimal Enter the octal number: 32 Decimal:=26 C:\corejava>_

# Convert Octal to Decimal

Related Tutorials

Discuss: Convert Octal to Decimal   View All Comments

Subject (*):

benjamin
June 23, 2011
writig program which display octa to hexa decimal

renaefushay
February 9, 2012
information technology

i want to learn how to convert from octal to binary.