How to Swap two numbers in JAVA

import java.util.Scanner();

public class Swap{ 
public static void main(String args[]){

 Scanner sc = Scanner(System.in);
 int x,y,temp; 

x=sc.nextInt(); 
y=sc.nextInt();
 
temp=x; 
x=y; 
y=temp; 

System.out.println("value of x="+x); 
System.out.println("value of y="+y); 

}
}

Comments