Convert decimal value to binary value in Java
Description
The following code shows how to convert decimal value to binary value.
Example
//from ww w. ja v a 2 s. c o m
public class Main{
public static void main(String[] argv){
int i = 42;
System.out.println(i + " as binary digits (bits) is " + Integer.toBinaryString(i));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »