```
public int totalHammingDistance(int[] nums) {
int total=0;
int n=nums.length;
for(int i=0;i<n;i++){
for(int j=i; j<n;j++){
total+=Integer.bitCount(nums[i]^nums[j]);
}
}
return total;
}
```

thanks @shawngao

https://discuss.leetcode.com/topic/72093/java-1-line-solution-d

Is the Time Complexity O(n^2)? Space O(1)? Correct me if I were wrong..