bitwise OR (on array)

后端 未结 2 626
无人及你
无人及你 2021-01-29 11:16

I need to perform bitwise OR of two arrays of byte in Java. How can I do so?

byte a= new byte[256];
byte b= new byte[256];

byte c; /*it should contain informati         


        
2条回答
  •  深忆病人
    2021-01-29 12:17

    Thats as simple as using the | operator and a loop:

    public static byte[] byteOr(byte[] a, byte[] b) {
        int len = Math.min(a.length, b.length);
        byte[] result = new byte[len];
        for (int i=0; i

提交回复
热议问题