I\'m tring to create an arraylist of different class instances. How can I create a list without defining a class type? (
List
List<Object> objects = new ArrayList<Object>();
objects
list will accept any of the Object
You could design like as follows
public class BaseEmployee{/* stuffs */}
public class RegularEmployee extends BaseEmployee{/* stuffs */}
public class Contractors extends BaseEmployee{/* stuffs */}
and in list
List<? extends BaseEmployee> employeeList = new ArrayList<? extends BaseEmployee>();