We make a class with two methods one for input and other for conversion and access this by object of this class. We first take the input as Octal from user. We define a method as convert() to convert the user’s input to Decimal.
Here is the source code of the Java Program to Convert Octal to Decimal. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
System.out.println("Octal to Decimal");
scan = new Scanner(System.in);
System.out.println("\nEnter the number :");
num = Integer.parseInt(scan.nextLine(), 8);
String decimal = Integer.toString(num);
System.out.println("Decimal Value is : " + decimal);
public static void main(String args)
Octal_Decimal obj = new Octal_Decimal();
$ javac MainClass.java $ java MainClass Octal to Decimal Enter the number : 10 Decimal Value is : 8
Sanfoundry Global Education & Learning Series – 1000 Java Programs.