@@ -0,0 +1,954 @@
+/**%0A * %0A */%0Apackage com.shanlin.demo.utils;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * @author shanlin%0A *%0A */%0Apublic class BinaryUtil %7B%0A%09public static final int type1 = 0x0002;%0A%09public static final int type2 = 0x0004;%0A%09public static final int type3 = 0x0008;%0A%09public static final int type4 = 0x0010;%0A%09public static final int type5 = 0x0020;%0A%09public static final int type6 = 0x0040;%0A%09public static final int type7 = 0x0080;%0A%09public static final int type8 = 0x0100;%0A%09%0A%09public static List%3CInteger%3E getCombination(int mix)%7B%0A%09%09List%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A%09%09String bin = Integer.toBinaryString(mix);%0A%09%09%0A%09%09char c;%0A%09%09char%5B%5D  bins = bin.toCharArray();%0A%09%09System.out.println(bin);%0A%09%09for (int i = 0; i %3Cbins.length; i++) %7B%0A%09%09%09c = bins%5Bi%5D;%0A%09%09%09if (c == '1') %7B%0A%09%09%09%09list.add(2%3C%3C(bins.length-i-2));%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return list;%0A%09%7D%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09System.out.println(getCombination(type1%7Ctype7%7Ctype8));%0A%09%7D%0A%7D%0A

添加2进制处理