import java.io.*;
class Swap
{
void swap(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
System.out.print("after swap---");
System.out.print(x+" ,");
System.out.print(y);
}
void swap2(int x,int y)
{
x=(x+y)-x;
y=(x+y)-y;
System.out.print("after swap---");
System.out.print(x+" ,");
System.out.print(y);
}
}
class Swapdemo
{
public static void main(String[] args) throws IOException
{
InputStreamReader id=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(id);
Swap s=new Swap();
System.out.println("enter two values");
int x=Integer.parseInt(br.readLine());
int y=Integer.parseInt(br.readLine());
s.swap(x,y);
//s.swap2(x,y);
}
}
No comments:
Post a Comment