简体   繁体   中英

Bitwise XOR operation in Java

I am facing this error while executing my program.

"bad operand types for binary operator '^' first type:int second type:int[]"

int temp1;
     for(int m = 1;m<height;m++)
     {
         temp1 = 2*m-1;
         for(int n = 0;n<width;n++)
         {
             r[temp1][n] = r[temp1][n]^Kc[n];
         }
     }

This will help me alot, Thanks.

You can apply the ^ operator on two int s, not on an int and an int array.

Based on the error message, Kc[n] is an array of int .

You can apply the operator on two int s :

r[temp1][n] = r[temp1][n]^Kc[temp1][n];

I have no idea if the indices make sense (since I don't know the dimensions of the 2 arrays), so you might have to change them.

The error message is saying that Kc[n] is an array of int s. It needs to be an int .

If you mean for Kc[n] to be an integer, you've miss-declared it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM