//Swapping of two numbers
public class Swapping
{
public static void swap(int i,int j)
{
int temp=i;
i=j;
j=temp;
System.out.println("After swapping i = " + i + " j = " + j);
}
public static void main(String[] args)
{
int i=1;
int j=2;
System.out.println("Before swapping i="+i+" j="+j);
swap(i,j);
}
}
No comments:
Post a Comment