java中如何执行按位异或运算?
package org.nhooo.example.lang;
public class XORDemo {
public static void main(String[] args) {
int numberA = 16;
int numberB = 32;
//运算符^用于执行按位异或运算
int result = numberA ^ numberB;
System.out.println(numberA + " ^ " + numberB + " = " + result);
//以二进制格式打印结果
System.out.println(Integer.toBinaryString(numberA) +
" ^ " + Integer.toBinaryString(numberB) +
" = " + Integer.toBinaryString(result));
}
}该程序将输出以下输出:
16 ^ 32 = 48 10000 ^ 100000 = 110000
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短