Although a List
is a subclass of Collection
it is not a class
; it is an interface
. On your second line, you cannot construct an object of type List
.
If you use an ArrayList
instead (e.g.: List lst = new ArrayList();
, and import java.util.ArrayList
) what youa re doing should work.