java.lang.Integer类将原始类型int的值包装在对象中。类型为Integer的对象包含一个类型为int的字段。
Integer类的toBinaryString()方法将整数参数的字符串表示形式作为基数中的无符号整数返回
import java.util.Scanner;
public class DecimalToBinary {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter a decimal number ::");
int decimal = sc.nextInt();
String result = Integer.toBinaryString(decimal);
System.out.println("Binary value of the given decimal number is ::"+result);
}
}输出结果
Enter a decimal number :: 444 Binary value of the given decimal number is ::110111100