日期:2014-05-20 浏览次数:20667 次
public static void main(String[] args) { System.err.println(Integer.toBinaryString(20)); }
------解决方案--------------------
public class MyTestMain { public StringBuffer getBint(int dec,StringBuffer result) { result.insert(0, dec%2); dec=dec/2; if(dec>1) result=getBint(dec,result); else result.insert(0, dec%2); return result; } public static void main(String[] args) { MyTestMain mtm=new MyTestMain(); System.out.print(mtm.getBint(20, new StringBuffer())); } }