Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Convert Binary to Decimal example

  1. /*
  2.  * Convert Binary to Decimal example. Program to convert binary number
  3.  * to decimal number.
  4.  */
  5.  
  6. public class BinaryToDecimal {
  7.  
  8.  public static void main(String args[]){
  9.  
  10.   //string having binary number
  11.   String binaryString = new String("10101");
  12.  
  13.   /*
  14.    * To convert binary number to decimal number use
  15.    * static parseInt method of Integer wrapper class.
  16.    *
  17.    * Radix will be 2 in this case.
  18.    */
  19.  
  20.   int dNumber = Integer.parseInt(binaryString, 2);
  21.  
  22.   System.out.println("Binary number converted to decimal number: " + dNumber);
  23.  
  24.  }
  25. }
Your rating: None Average: 5 (1 vote)
Share this

Post new comment