Here you can find the source of bitCount(int i)
static int bitCount(int i)
//package com.java2s; public class Main { static int bitCount(int i) { if (i == 0) { return 32; }//from w ww . j a va 2s . co m int j = i; int n = 0; while (j != 0) { j &= (j - 1); ++n; } return n; } }