I want to add specific elements to ArrayList. I can achieve this by doing this:
List<Employee> list = new ArrayList<Employee>();
List<String> list = new ArrayList<String>();
But, I want to create new List which hold either Employee or String objects and nothing else:
// This is
List<String or Employee> list = new ArrayList<String or Employee>();
Is this possible? If yes please explain me.
??? element = list.get(0);What would???be?