Swapping Two Numbers
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 = ...
Feb 24, 20241 min read