java convert octal to decimal

Solutions on MaxInterview for java convert octal to decimal by the best coders in the world

showing results for - "java convert octal to decimal"
Giulio
14 Apr 2018
1import java.util.Scanner;
2public class OctalToBinaryJava
3{
4   public static void main(String[] args)
5   {
6      Scanner sc = new Scanner(System.in);
7      System.out.println("Please enter octal number: ");
8      int octal = Integer.parseInt(sc.nextLine(), 8);
9      String strBinary = Integer.toBinaryString(octal);
10      System.out.println("Binary value is: " + strBinary);
11      sc.close();
12   }
13}
Iris
24 Feb 2016
1public class OctalToDecimalDemo
2{
3   public static void main(String[] args)
4   {
5      String strOctal = "141";
6      // converting octal to decimal number using Integer.parseInt() method
7      int decimal = Integer.parseInt(strOctal, 8);
8      System.out.println(decimal);
9   }
10}