In this example, we will convert integer to binary number with toBinaryString method of Integer wrapper class.
Source Code
package com.beginner.examples;
public class GetBinary {
public static void main(String[] args) {
Integer integer = new Integer(60);
// Use the toBinaryString() method in the Integer class to get the
// binary number
String strBinary = Integer.toBinaryString(integer);
System.out.println(integer + ":" + strBinary);
}
}
Output:
60:111100