//package com.nowjava;
/*来自
nowjava.com - 时 代 Java*/
public class Main {
public static void main(String[] argv) throws Exception {
int n = 2;
System.out.println(countBits(n));
}
/**
* Counts the number of bits set in an integer <i>n</i>.
*
* @param n
* The integer to count.
* @return The number of bits set in n.
*/
public static int countBits(int n) {
int total; // Holds the number of bits set.
for (total = 0; n != 0; ++total) {/**来自 时 代 J a v a - nowjava.com**/
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。