Java Integer toBinaryString() MethodThe toBinaryString() method of Java Integer class returns a string representation of the integer argument as an unsigned integer in binary base 2. Note: If the argument is snegative, the unsigned integer value is the argument plus 232otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0', otherwise, the first character representation of the unsigned magnitude will not be the zero character.Explanation:Syntax:Following is the declaration of toBinaryString () method: Parameter:
Returns:The toBinaryString() method returns the string representation of the unsigned integer value represented by the argument in binary (base 2). Exceptions:NA Compatibility Version:Java 1.0.2 and above Example 1Output: Number = 121 Binary representation is = 1111001 Example 2Output: Enter the Number = 56 Number = 56 Binary representation is = 111000 Example 3Output: 10100 11111111111111111111111111101100 1111101000 11111111111111111111110000011000 Next TopicJava-integer-tohexstring-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India