Source Code
import java.util.Scanner;class InterchangeNo{
public void swap(){
int x, y, temp;
System.out.println("Enter any two numbers for swaping them:");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
System.out.println("Before Swapping it was\nx = "+x+"\ny = "+y);
temp = x;
x = y;
y = temp;
System.out.println("After Swapping it is\nx = "+x+"\ny = "+y);
}
}
class Main{
public static void main(String args[]){
InterchangeNo obj=new InterchangeNo();
obj.swap();
}
}
No comments: