Here you will get program to convert binary to decimal in Java. We can convert a binary number into decimal in two ways, using Integer.parseInt() method and by using your own logic. Below I have shared program for both the methods. Also Read: Convert Decimal to Binary in Java Convert Binary to Decimal in Java Method 1: Using Integer.parseInt() We can directly use parseInt() method of Integer class for binary to decimal conversion.

import java.util.Scanner; public class JavaB2D { public static void main(String args[]){ int decimalNumber; String binaryNumber; Scanner sc = new Scanner(System.in); System.out.println("Enter a binary number:"); binaryNumber = sc.nextLine(); decimalNumber = Integer.parseInt(binaryNumber, 2); System.out.println("Decimal number is " + decimalNumber); } } 
Output Enter a binary number: 11 Decimal
Read more