In this example we will show the method to convert a binary number to an Integer in Java.
Source Code
package com.beginner.examples;
public class BinaryToInteger {
public static void main(String[] args) {
String strBinary = "100111";
Integer integer = Integer.parseInt(strBinary, 2); // convert a binary number to an Integer
System.out.println(integer);
}
}
Output:
39