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 G 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 Like