Java lang.Integer.toBinaryString() method Last Updated : 05 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The java.lang.Integer.toBinaryString() method returns a string representation of the integer argument as an unsigned integer in base 2. It accepts an argument in Int data-type and returns the corresponding binary string. Syntax: public static String toBinaryString(int num) Parameter : The function accepts a single mandatory parameter num num - This parameter specifies the number to be converted to binary string. It is of int data-type Return Value: This function returns the string representation of the unsigned Integer value represented by the argument in binary (base 2). Examples: Input : 10 Output : 1010 Input : 9 Output : 1001 Java // Java program to demonstrate // java.lang.Integer.toBinaryString() method import java.lang.Math; class Gfg1 { // driver code public static void main(String args[]) { int l = 10; // returns the string representation of the unsigned int value // represented by the argument in binary (base 2) System.out.println("Binary is " + Integer.toBinaryString(l)); l = 9; System.out.println("Binary is " + Integer.toBinaryString(l)); } } Output: Binary is 1010 Binary is 1001 Comment More infoAdvertise with us Next Article Java lang.Integer.toBinaryString() method gopaldave Follow Improve Article Tags : Misc Java Java-lang package Java-Functions java-math Java-Integer +2 More Practice Tags : JavaMisc Similar Reads BigInteger toString() Method in Java BigInteger Class offers 2 methods for toString(). toString(int radix): The java.math.BigInteger.toString(int radix) method returns the decimal String representation of this BigInteger in given radix. Radix parameter decides on which number base (Binary, octal, hex etc) it should return the string. I 3 min read Integer toOctalString() Method in Java Octal is the base-8 number system and uses the digits 0 to 7 in operation. Octal is widely used in computing on systems like the PDP-8, and IBM mainframes employed 12-bit, 24-bit or 36-bit words. The Java.lang.Integer.toOctalString() method is a built-in function in Java that is used to return a str 3 min read Java lang.Long.toBinaryString() method with Examples The java.lang.Long.toBinaryString() method returns a string representation of the long argument as an unsigned integer in base 2. It accepts an argument in Long data-type and returns the corresponding binary string. Syntax: public static String toBinaryString(long num) Parameters : The function acce 3 min read Java lang Integer.toHexString() Method with Examples The Java.lang.Integer.toHexString() is a built-in function in Java which returns a string representation of the integer argument as an unsigned integer in base 16. The function accepts a single parameter as an argument in Integer data-type. Syntax : public static String toHexString(int num) Paramete 3 min read MathContext toString() Method in Java The MathContext.toString() method in Java is a part of java.math package. This method is used to define the precision and rounding behaviour for BigDecimal operations. This method returns the string representation of a MathContext object's context settings. The string returned represents the setting 2 min read BigInteger setBit() Method in Java The java.math.BigInteger.setbit(index) method returns a Big-integer whose value is equivalent to this Big-integer with the designated bit set. The method computes (this | (1<<n)). The bit at index n of binary representation of Big-integer will be set means converted to 1. Syntax: public BigInt 2 min read BigInteger toByteArray() Method in Java The java.math.BigInteger.toByteArray() method returns an array of bytes containing the two's-complement representation of this BigInteger. The most significant byte of the byte array is present in the zeroth element. The returning array from this method contains sign bit and the minimum number of by 2 min read Integer toString() in Java The java.lang.Integer.toString() is an inbuilt method in Java which is used to return the String object representing this Integer's value. Syntax : public static String toString() Parameters: The method does not accept any parameters. Return Value:The method returns the string object of the particul 5 min read BigInteger testBit() Method in Java prerequisite : BigInteger Basics The java.math.BigInteger.testBit(index) method returns true if and only if the designated bit is set. This method Computes (this & (1<<n)) != 0). Syntax: public boolean testBit(int n) Parameter: The method takes one parameter n of integer type which refers 2 min read Java lang Long.toOctalString() Method with Examples The Java.lang.Long.toOctalString() function is a built-in function in Java that returns a string representation of the long argument as an unsigned integer in base 8. Syntax: public static int toOctalString(long num) Parameters: The function accepts a single mandatory parameter num, which is to be c 2 min read Like