number of bits set to 1 in an integer java 8 code example Example: bit counting countBits = (n) => n.toString(2).split("0").join("").length;