You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//And when the seven thunders had uttered their voices, I was about to write: and I heard a voice from heaven saying unto me, Seal up those things which the seven thunders uttered, and write them not. (Revelation 10:4)
packagecom.javarush.task.task30.task3006;
/*
Swap по-новому
*/
publicclassSolution {
publicstaticvoidmain(String[] args) {
/* expected output
x=4, y=5
x=5, y=4
*/
Pairpair = newPair(4, 5);
System.out.println(pair);
pair.swap();
System.out.println(pair);
}
}
/*
Swap по-новому
В классе Pair реализуй метод swap, который должен для x, y менять местами их значения.
Можно использовать только операции:
1) Исключающее или.
2) Присваивание.
3) Исключающее или с присваиванием.
Не оставляй комментарии, не меняй остальной код.
Требования:
1. В классе Pair должен присутствовать метод swap().
2. В классе Pair в методе swap() используй только разрешенные операции.
3. Вызов метода swap() должен поменять значения полей x и y.