Java

Java Program to convert an Integer to Binary String

Integer Wrapper class have a static method toBinaryString() which converts the given Integer to the Binary String.

Let us go through a small program which can demonstrate to us the same part.

class IntToBinary

{

 public static void main(String[] args)

 {

  int i=25;

  String binaryString=Integer.toBinaryString(i);

  System.out.println(i+" in binary is "+binaryString);

 }

}
Here the number 25 is converted to Binary String 11001

 

 

Related Posts

language_img
Java

Widening vs Boxing

May 4, 2016

language_img
Java

What is Widening?

Apr 26, 2016

Table Of Contents

;