Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java - Swap two numbers without using temp var
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int x = 10; int y = 15; x = x + y; // 25 temp x y = x - y; // 25 - 15 = 10 x = x - y; // 25 - 10 = 15 System.out.println("x = " + x); System.out.print("y = " + y); } }
run
|
edit
|
history
|
help
0
jb11.0 threads tick tock
Implement Queue with Limited Size of Arrays
bikeride
Edna Garcia
laba3
Hello world
1(E)
1*2-3+4
Elevator Sim
Assignment for Web Software Developer position