How to convert a Binary String to a base 10 integer in Java

You need to specify the radix. There’s an overload of Integer#parseInt() which allows you to.

int foo = Integer.parseInt("1001", 2);

Leave a Comment