How to Convert a Binary Number to an Integer in Java


In this example, we will learn 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
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments