public static void main(String[] args) {
    byte[] ip = new byte[]{(byte) 192, (byte) 168, 1, 2};
    byte[] mask = new byte[]{(byte) 255, (byte) 255, (byte) 254, 0};
    byte[] netAddress = getNetAddress(ip, mask);

    print(ip);          //11000000 10101000 00000001 00000010
    print(mask);        //11111111 11111111 11111110 00000000
    print(netAddress);  //11000000 10101000 00000000 00000000



}

public static byte[] getNetAddress(byte[] ip, byte[] mask) {
    byte x,y, z;
    byte [] adress = new byte[4];

    for(int i=0; i<4; i++){
        x = ip[i];
        y = mask[i];
        z = (byte)x &(byte)y;  - //ПОЧЕМУ НЕ РАБОТАЕТ? Интерпритатор говорит, что "видит" int вместо byte

        adress[i] = (byte) z;
    }

    return adress;
}