Hello everyone
first of all thanks to daniweb and all users to help me lots of time.
now come to problem i am learning java from last one month today i wrote a program to swap two objects it is running but not performing desired task.
all instance fields are same after swaping as were earlier.
class emp{
int i,j;
emp(int i,int j)
{
this.i=i;
this.j=j;
}
void showdata()
{
System.out.println(i+"\n"+j);
}
static void sw(emp a, emp b)
{
emp temp;
temp=a;
a=b;
b=temp;
}
}
class swap{
public static void main(String arg[])
{
emp e1=new emp(10,10);
emp e2=new emp(20,20);
e1.showdata();
e2.showdata();
emp.sw(e1,e2);
e1.showdata();
e2.showdata();
}
}
please tell me wheres the problem.