In this example we will show the method to swap number in Java.
Source Code
package com.beginner.examples;
public class SwapNumber {
public static void main(String[] args){
int m = 2020;
int n = 6;
int k = n; //temporary variable
//swap the value
n = m;
m = k;
System.out.println("m = " + m + " and n = " + n);
}
}
Output:
m = 6 and n = 2020