NumSetBits { public static long getNumSetBitsBetweenWholeBytes(byte[] array, int firstByte, int lastByte) { long totalBits = 0; for (int index = firstByte; index <= lastByte; index++) { totalBits += getNumSetBits(array[index], 0, 7); } return totalBits; }  static long getNumSetBits(byte[] leds, long offset, long length); static int getNumSetBits(byte b, int startOffset, int endOffset); static long getNumSetBitsBetweenWholeBytes(byte[] array,
			int firstByte, int lastByte);  }
@Test public void getNumSetBits_ByteArray() { byte[] array = new byte[] { (byte) 100, (byte) 255, (byte) 255, (byte) 175 }; assertEquals(25, NumSetBits.getNumSetBitsBetweenWholeBytes(array, 0, 3)); assertEquals(16, NumSetBits.getNumSetBitsBetweenWholeBytes(array, 1, 2)); }