// 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) 
public class ConCoVar {
    public static class P {
    }
    public static class C1 extends P {
    }
    public static class C2 extends P {
    }
    public static class Container<T> {
        private T o;
        public Container(T o) {
            this.o = o;
        }
        public T getO() {
            return o;
        }
        public void setO(T o) {
            this.o = o;
        }
    }
    public static class X<T extends P> {
        public void m(Container<T> c) {
            c.getO();
            c.setO(c.getO());
        }
    }
    public static class Y {
        public void m(Container<? extends P> c) {
            c.getO();
            //c.setO(c.getO());
        }
    }
    public static void main(String[] args) {
        X<C1> x1 = new X<C1>();
        x1.m(new Container<C1>(new C1()));
        //x1.m(new Container<C2>(new C2()));
        X<C2> x2 = new X<C2>();
        //x2.m(new Container<C1>(new C1()));
        x2.m(new Container<C2>(new C2()));
        Y y = new Y();
        y.m(new Container<C1>(new C1()));
        y.m(new Container<C2>(new C2()));
    }
}
