int x = 122;
int count = 0;
while(x != 0)
{
int z = x;
x = x & ( x - 1 );
// 此为1的索引
z = Integer.toBinaryString(z-x).length()-1;
// count为有多少位1
count++;
}
int count = 0;
while(x != 0)
{
int z = x;
x = x & ( x - 1 );
// 此为1的索引
z = Integer.toBinaryString(z-x).length()-1;
// count为有多少位1
count++;
}