Quick actions

cmd+k|ctrl+k

Navigation

Languages

Prototype Design Pattern

Snippet info

Language

Java

Visibility

public

Author

1ndroidbella

Created

2019-08-07T16:54:23Z

Updated

2019-08-07T16:54:23Z

import java.util.List;

class Main {
    public static void main(String[] args) {
        Employees emps = new Employees();
		emps.loadData();
		
		//Use the clone method to get the Employee object
		Employees empsNew = (Employees) emps.clone();
		Employees empsNew1 = (Employees) emps.clone();
		List<String> list = empsNew.getEmpList();
		list.add("Hassan");
		List<String> list1 = empsNew1.getEmpList();
		list1.remove("Hicham");
		
		System.out.println("emps List: "+emps.getEmpList());
		System.out.println("empsNew List: "+list);
		System.out.println("empsNew1 List: "+list1);
    }
}
INFO