This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
No elements of this array will ever be null; only object references can be null, and a byte is not an object reference. If you want to find out if any elements are 0: yes, in general, you need to check with a loop.
I agree, I think you would need to use a loop.... but here are some really bad alternatives, just for fun:
// Could probably be improved with some Pattern matching, and could // definitely be improved with fewer (ideally 1) invocation of // Arrays.toString().... but what fun would that be? ((Arrays.toString(bb).indexOf(" 0,") < 0) && (Arrays.toString(bb).indexOf("[0,") < 0) && (Arrays.toString(bb).indexOf(" 0]") < 0) && (!Arrays.toString(bb).equals(""))
// Have to clone only if you want to maintain the original ordering Arrays.sort(bb.clone()).binarySearch((byte)0)
// hrmmm.... I bet this is looping internally anyway... Arrays.aslist(bb).contains((byte)0)