-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjava1.java
More file actions
31 lines (26 loc) · 730 Bytes
/
java1.java
File metadata and controls
31 lines (26 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Java Program to Swap Two values using third variable
// using temp variable
// Importing generic libraries
import java.util.*;
class GFG {
// Function to swap two numbers
// Using temporary variable
static void swapValuesUsingThirdVariable(int m, int n)
{
// Swapping the values
int temp = m;
m = s;
n = temp
System.out.println("Value of m is " + m
+ " and Value of n is " + n);
}
// Main driver code
public static void (String[] args)
{
// Random integer values
int m = 9, n = 5;
// Calling above function to
// reverse the numbers
swapValuesUsingThirdVariable(m, n);
}
}