You are on page 1of 2

public class Employee {

private int id;

private String name;

public Employee (int id, String name) {

this.id = id;

this.name = name;

/**********in part 2*****************/

public class Employee {

private int id;

private String name;

public Employee (int id, String name) {

this.id = id;

this.name = name;

public String getName() {

return this.name;

}
public void setName(String name) {

this.name=name;

/* ** *Solution.java */

public class Solution {

private static void SwapName(Employee e_1, Employee e_2) {

String tempHolder = e_1.getName();

e_1.setName(e_2.getName());

e_2.setName(tempHolder);

public static void main(String[] args) {

Employee e1 = new Employee(1, "aaa");

Employee e2 = new Employee(2, "bbb");

SwapName(e1, e2);

System.out.println(e1.getName()+" "+e2.getName());

You might also like