Skip to content

Instantly share code, notes, and snippets.

@TrevCan
Last active October 1, 2020 19:18
Show Gist options
  • Save TrevCan/23db1e6eb967fc2a52a72aace7556bc7 to your computer and use it in GitHub Desktop.
Save TrevCan/23db1e6eb967fc2a52a72aace7556bc7 to your computer and use it in GitHub Desktop.
swap 2 variables without temp variable.
class Scratch {
public static void main(String[] args) {
double a = -9, b = -11;
System.out.println("a: " + a + "\nb: " + b);
a = a * b;
b = a/b;
a = a/b;
System.out.println("a: " + a + "\nb: " + b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment