// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.ArrayList;

public class GWC {
    public static void mstd(ArrayList<P> lst) {
        P o = lst.get(0);
        lst.add(new C2());
    }
    public static void mspec(ArrayList<? extends P> lst) {
        P o = lst.get(0);
        // syntax error - for good reasons: we can not add a C2 to this list
        //lst.add(new C2());
    }
    public static void main(String[] args) {
        // basic
        ArrayList<P> lst1 = new ArrayList<P>();
        lst1.add(new C1());
        mstd(lst1);
        // problem
        ArrayList<C1> lst2 = new ArrayList<C1>();
        lst2.add(new C1());
        // syntax error - for good reasons: we can not add a C2 to this list
        //mstd(lst2);
        // solution
        mspec(lst2);
    }
}

class P {
}

class C1 extends P {
}

class C2 extends P {
}
