+ 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.

25th Jan 2018, 3:43 AM
Tim Millar
Tim Millar - avatar
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?
26th Feb 2018, 1:51 PM
Михаил «Sarf» Дружинин
Михаил «Sarf» Дружинин - avatar
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; }
26th Feb 2018, 9:12 PM
Tim Millar
Tim Millar - avatar