package java_programs;

/**
 * Class that provides a method to count the number of 1 bits in the binary representation of an integer.
 */
public class BITCOUNT {
    /**
     * Counts the number of set bits (1s) in the binary representation of an integer.
     * 
     * @param n the integer to compute the bit count for
     * @return the number of set bits in the binary representation of n
     */
    public static int bitcount(int n) {
        int count = 0;
        while (n != 0) {
            n = n & (n - 1);
            count++;
        }
        return count;
    }
}