byte not - Java java.lang

Java examples for java.lang:byte Array Bit Operation

Description

byte not

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] bytes = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        bytesNot(bytes);/* ww  w . ja  va2  s . com*/
    }

    public static final byte OxFF = -1;

    public static void bytesNot(byte[] bytes) {
        for (int i = 0; i < bytes.length; ++i) {
            bytes[i] = (byte) (bytes[i] ^ OxFF);
        }
    }
}

Related Tutorials