import java.util.*;
import java.lang.*;
import java.io.*;
public class SwapNumbers
{
public static void main(String[] args)
int first = 4, second = 5;
System.out.println("--Before swap--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
int temp = first;
first = second;
second = temp;
System.out.println("--After swap--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
}
}Java
Program to swap two numbers using temporary variable.

Written by
View ProfileNikhil Juneja
Passionate software developer and technical contributor at TutorialsLink.
