You need to specify the radix. There’s an overload of Integer#parseInt()
which allows you to.
int foo = Integer.parseInt("1001", 2);
More Related Contents:
- Converting an int to a binary string representation in Java?
- Convert binary string to byte array
- Need some advice on split() method in Java [closed]
- how to get the first two bytes from a string in java?
- Why is char[] preferred over String for passwords?
- Split string with dot as delimiter
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- Is there a way to instantiate a class by name in Java?
- Check if String contains only letters
- Check string for palindrome
- Test if a string contains any of the strings from an array
- length and length() in Java
- Is String Literal Pool a collection of references to the String Object, Or a collection of Objects
- Converting Decimal to Binary Java
- How to convert a byte to its binary string representation
- Closing a Scanner throws java.util.NoSuchElementException
- The most sophisticated way for creating comma-separated Strings from a Collection/Array/List?
- Which loop has better performance? Why?
- How much memory does a string use in Java 8?
- How to replace a String in java which contains dot?
- String concatenation complexity in C++ and Java [duplicate]
- What is the best way to extract the first word from a string in Java?
- How to replace ” \ ” with ” \\ ” in java
- Validate a file name on Windows
- Print out elements from an Array with a Comma between the elements
- substring index range
- How to replace a substring of a string [duplicate]
- How do I get the last character of a string?
- Java Encode file to Base64 string To match with other encoded string
- How to convert hex string to float in Java?