这是一种使用按位XOR(^)运算符仅在一行中交换Java 中的两个变量的方法。class Swap{ public static void main (String[] args) { int x = 5, y = 10; x = x ^ y ^ (y = x); System.out.println("New values of x and y are "+ x + ", " + y); }} 输出:x和y的新值为10、5