Octal To Decimal Conversion In Java

Let us learn octal to decimal conversion in java.

The conversion from octal to decimal takes place with the help of Integer wrapper class. This class provides a method Integer.parseInt(String s, int radix) which converts binary, hexadecimal and octal number to decimal number.

The parameters in the above method namely “String s” and “int radix” indicates

String s – binary, hexadecimal and octal number,

int radix – in what base the first argument is represented.

The method Integer.parseInt(String s, int radix) size is less than 32-bits. However, the size greater than 32-bits will throw an unchecked runtime java.lang.NumberFormatException.

example: Octal To Decimal Conversion In Java

Also Read – Convert Decimal to Octal Java Program

import java.util.Scanner;

public class Octal_To_Decimal_Conversion {

int number;

void get_Value(){
System.out.println("Octal To Decimal Conversion In Java");
Scanner sc = new Scanner(System.in);
System.out.println("Please enter number for conversion: ");
number = Integer.parseInt(sc.nextLine(),8);

void convert_Value(){
String decimal = Integer.toString(number);
System.out.println("Converted Decimal value is: " + decimal);

public static void main(String[] args) {

Octal_To_Decimal_Conversion obj1 = new Octal_To_Decimal_Conversion();


Octal To Decimal Conversion In Java

About the author


View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *