public class Test { public static void main(String[] args){ int i = 1; String s = toFullBinaryString(i);//整形打印出二进制整形 System.out.println(s); System.out.println(Integer.parseInt(s));//将二进制转换成整形 } private static String toFullBinaryString(int x) { int[] buffer = new int[Integer.SIZE];//Integer是32位的 for (int i = (Integer.SIZE - 1); i >= 0; i--) { buffer[i] = x >> i & 1; } String s = ""; for (int j = (Integer.SIZE - 1); j >= 0; j--) { s = s + buffer[j]; } return s; } }