Home Tutorial Java Core Java Convert Octal to Binary

 
 

Java Convert Octal to Binary
Posted on: December 4, 2012 at 12:00 AM
In this tutorial, you will learn how to convert octal to binary.

Java Convert Octal to Binary

In this tutorial, you will learn how to convert octal to binary.

Java has provide different ways to change the number system of different numbers. You can convert and decimal to octal, decimal to binary, decimal to hexadecimal or vice versa. Here is an example of converting octal number to binary.

Example:

import java.io.*;
class ConvertOctalToBinary{
    public static void main(String[] args)throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter octal number: ");
        String oct = br.readLine();
        int i= Integer.parseInt(oct,8);
        String binary=Integer.toBinaryString(i);
        System.out.println("Octal Number: "+binary);
    }
}

Output:

Enter octal number: 32
Octal Number: 11010

Related Tags for Java Convert Octal to Binary:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.