< p >(假设您不想调用基数函数)< /p > int count = 0; for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) { count++; } 查看javadoc文档
long[]
,并对其中的每个元素调用Long#bitCount
方法。 - Thilo