Answers for "swap two variables in java in single line"

1

swap two variables in java in single line

// swap two variables in java in single line
public class SwapTwoVariablesInOneLine
{
   public static void main(String[] args)
   {
      int x = 23;
      int y = 75;
      System.out.println("Before swapping two numbers: x = " + x + " y = " + y);
      x = x ^ y ^ (y = x);
      System.out.println("After swapping two numbers: x = " + x + " y = " + y);
   }
}
Posted by: Guest on February-22-2021

Code answers related to "swap two variables in java in single line"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language