private static boolean hasCommonPrefix(byte[] address,byte[] address2){
  return address[0] == address2[0] && address[1] == address2[1];
}

private static boolean hasCommonPrefix ( byte [ ] address , byte [ ] address2 ) { return address [ 0 ] == address2 [ 0 ] && address [ 1 ] == address2 [ 1 ] ; }
checks if two addresses have a common prefix ( first 2 bytes ) . example : 192 . 168 . ? ? ? . ? ? ? works also with ipv6 , but accepts probably too many addresses
