public class Solution {
// you need to treat n as an unsigned value
public static int hammingWeight(int n) {
int count = 0;
while(n!=0) {
int check = n & 1;
count = count + check;
n = n>>>1; // zero filled right shift, eventually the no. "n" will become zero
}
return count;
}
}