Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thmain
Created August 20, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/dcc837622616fc16f99317e23b3758be to your computer and use it in GitHub Desktop.
Save thmain/dcc837622616fc16f99317e23b3758be to your computer and use it in GitHub Desktop.
public class SwapNumbers {
public static void swap(int a, int b){
System.out.println("first number: " + a + " second number: " + b);
a = a + b;
b = a - b;
a = a - b;
System.out.println("After Swappng: first number: " + a + " second number: " + b);
}
public static void main(String[] args) {
int a = 3;
int b = 5;
swap(a,b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment