// 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;
import java.util.List;

public class WrongWay {
    public static void main(String[] args) {
        WWHolder a = new WWHolder("AAA");
        System.out.println("AAA:");
        a.print();
        WWHolder b = new WWHolder("BBB");
        System.out.println("BBB:");
        b.print();
        System.out.println("AAA again:");
        a.print();
    }
}

class WWHolder {
    public static String magic;
    private List<WWP> lst;
    public WWHolder(String s) {
        magic = s;
        lst = new ArrayList<WWP>();
        lst.add(new WWC1());
        lst.add(new WWC2());
    }
    public void print() {
        for(WWP o : lst) {
            o.print();
        }
    }
}

abstract class WWP {
    public abstract void print();
}

class WWC1 extends WWP {
    @Override
    public void print() {
        System.out.println("I am a C1 in " + WWHolder.magic);
    }
}

class WWC2 extends WWP {
    @Override
    public void print() {
        System.out.println("I am a C2 in " + WWHolder.magic);
    }
}
