Using a temp variable int a = 5; int b = 10; int temp = a; a = b; b = temp; System.out.println("a = " + a); // Output: a = 10 System.out.println("b = " + b); // Output: b = 5 Without Using a temp variable (using addition and subtraction): int a = ...
I'm a software developer who love to solve coding problems and interact with people online to learn something new