Question: I want to write a method that will create a List of the type I define in the method parameters. So if I have 3 classes: `Student`, `Teacher` and `Janitor`, the method should create a `List` of whatever type is passed in

```
public void methodName(TYPE){  
    List<TYPE> results = new List<TYPE>();  
}

```

What should I be using for `TYPE`?

Answer: 
You can use JAVA generics. One way is to allow all class types to be acceptable, by this.. 

```
public <T> void methodName(Class<T> cl){  
    List<T> results = new ArrayList<T>();  
}

```

or a better way would be to make all classes you want to be accepted derive from an interface, say `Person` and then you can do.. 

```
public <T extends Person> void methodName(Class<T> cl){  
    List<T> results = new ArrayList<T>();  
}

```

This limits the set of classes accepted by the the method, to only those implementing `Person`.
You may want to check out [a question of mine](https://stackoverflow.com/q/8436055/483113), which, however, approaches the issue from the other side.

Basically Java has such a function already (feel free to go from there):

```
Collections.<String>emptyList()

```

to get an empty List with elements which are supposedly of type String. Java's source looks like this:

```
public static final List EMPTY_LIST = new EmptyList<Object>();
:
public static final <T> List<T> emptyList() {
  return (List<T>) EMPTY_LIST;
}

```