-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwapMethod.java
More file actions
23 lines (21 loc) · 644 Bytes
/
SwapMethod.java
File metadata and controls
23 lines (21 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Methods;
import java.util.Scanner;
public class SwapMethod {
public static void main(String[] args) {
// int a = 12;
// int b = 33;
// methods.swap(a,b);
Scanner input = new Scanner(System.in);
System.out.print("Please enter the numbers: ");
int num1 = input.nextInt();
int num2 = input.nextInt();
swap(num1, num2);
}
static void swap(int a, int b){
System.out.println("Before methods.swap : a = " + a + " b = " + b);
int temp = a;
a = b;
b = temp;
System.out.println("After methods.swap : a = " + a + " b = " + b);
}
}