Last active
October 1, 2020 19:18
-
-
Save TrevCan/23db1e6eb967fc2a52a72aace7556bc7 to your computer and use it in GitHub Desktop.
swap 2 variables without temp variable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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