Here you can find the source of bitcount(int num)
public static int bitcount(int num)
//package com.java2s; /**/*from w ww. ja va 2 s . c om*/ * HashMap?????????????????????????new?????????????????????????? * ???????? * code by guava-libraries.(Apache License 2.0) * https://code.google.com/p/guava-libraries/ * * @return HashMap???????????????????????? */ public class Main { public static int bitcount(int num) { int count = 0; while (num > 0) { count += num % 2; num /= 2; } return count; } }