Here you can find the source of dec2bin(int dec)
private static String dec2bin(int dec)
//package com.java2s; /*//www. jav a 2 s. c o m * (C) Copyright IBM Corp. 2008 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ public class Main { private static String dec2bin(int dec) { if (0 == dec) return "0"; StringBuffer sb = new StringBuffer(); while (dec != 0) { sb.append(1 == dec % 2 ? 1 : 0); dec >>= 1; } return sb.reverse().toString(); } }