I have the following variables:
byte[][] bytes;
byte[] value;
Is there a smart way to find the index of the first matching entry of value
in bytes
?
value
is NOT the same object as an entry in bytes
, it just has the same contents.
Of course you could just do:
int idx = -1;
for(int i=0;i<bytes.length;i++) {
if(Arrays.equals(value, bytes[i])) {
idx = i;
break;
}
}
// idx is index or -1 if not found
I was just wondering if it can get even easier.