Home Tutorial Java Core Java Convert Octal to Binary

 
 

Java Convert Octal to Binary
Posted on: December 4, 2012 at 12:00 AM
Advertisement
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
Advertisement

Related Tags for Java Convert Octal to Binary:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 4, 2012

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com