2007年7月21日 星期六

toBinaryString

以前寫程式時,常需要將十進位的數字轉成二進位,再進行計算。
Java在IntegerLong Class有提供一個static method叫做toBinaryString(),我們可以很方便的使用它。

int num = 18;
System.out.println(Integer.toBinaryString(num));

結果會印出
10010

0 意見: