+ 1
Challenge
Given this class. class Test { into a; Test(into i) { a = I} } write a method called swap() that exchanges the contents of the objects referred to by two Test object references.
2 Answers
+ 1
public static void swap(Test T1, Test T2) {
int buf = 0;
buf = T1.a;
T1.a = T2.a;
T2.a = buf;
}
Not hard, huh?
0
very good sir.. well done here is my version:
void swap(Test ob1, Test ob2) {
into t;
t = ob1.a;
ob1.a = ob2.a:
ob2.a = t;
}