package com.heima.test1;
import java.util.Scanner;
public class Test06 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入数字:");
int b=sc.nextInt();
String s=Integer.toBinaryString(b);
//System.out.println(s);
while(s.length() != 16){ //都转为多少个数的二进制就把16改为多少.
s=new StringBuilder(s).insert(0, "0").toString();
}
System.out.println(s);
}
} |