Java Byte Array And and(byte[] a, byte[] b)

Here you can find the source of and(byte[] a, byte[] b)

Description

and

License

Mozilla Public License

Declaration

public static byte[] and(byte[] a, byte[] b) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static byte[] and(byte[] a, byte[] b) {
        if (a.length != b.length) {
            throw new IllegalArgumentException("Arrays a and b should have equal length");
        }//from   www  . ja  v a  2  s . c  om
        byte[] result = new byte[a.length];
        for (int i = 0; i < a.length; i++) {
            result[i] = (byte) (a[i] & b[i]);
        }
        return result;
    }
}

Related

  1. and(byte[] a, byte[] b)
  2. and(byte[] a, byte[] b)
  3. and(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length)
  4. and(byte[] data1, byte[] data2)