Convert binary number to decimal number - Java Data Structure

Java examples for Data Structure:Algorithm

Description

Convert binary number to decimal number

Demo Code


public class Main {
        public static void main(String[] args) {
                 //declare string containing binary number
                 String strBinaryNumber = "111000";
               /*from   www . ja v  a2s .  co m*/
                 int decimalNumber = Integer.parseInt(strBinaryNumber,2);
                 System.out.println("Binary number converted to decimal number");
                 System.out.println("Decimal number is : " + decimalNumber);
               
        }
}

Result


Related Tutorials