xxxxxxxxxx
/* function definition to swap the values */
void swap(int *x, int *y) {
int temp;
temp = *x; /* save the value at address x */
*x = *y; /* put y into x */
*y = temp; /* put temp into y */
return;
}
xxxxxxxxxx
public class CallByReference {
String name;
void change(CallByReference r2) {
r2.name = "Rubel";
}
public static void main(String[] args) {
CallByReference r1 = new CallByReference();
r1.name = "Anis";
System.out.println("before calling : "+r1.name);
r1.change(r1);
System.out.println("after calling : "+r1.name);
}
}