Change identities

Report a typo

There is a class Person that has two fields: name and age. Your task is to implement the method changeIdentities. It should swap all information (age and name) between two persons p1 and p2.

It is known that objects p1 and p2 can't be null.

Write a program in Java 17
class Person {
String name;
int age;
}

class MakingChanges {
public static void changeIdentities(Person p1, Person p2) {
// write your code here

}
}
___

Create a free account to access the full topic