// 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 Wrap2 {
    public static void main(String[] args) {
        List<A2> lst = new ArrayList<A2>();
        lst.add(new B2("X", "Y"));
        lst.add(new A2("Z"));
        System.out.println(lst.contains(new B2("X", "Y")));
        System.out.println(lst.contains(new A2("X")));
        System.out.println(lst.contains(new B2("X", "Z")));
        System.out.println(lst.contains(new A2("W")));
    }
}

class A2 {
    private String a;
    public A2(String a) {
        super();
        this.a = a;
    }
    public String getA() {
        return a;
    }
    public void setA(String a) {
        this.a = a;
    }
    @Override
    public int hashCode() {
        return a.hashCode();
    }
    @Override
    public boolean equals(Object o) {
        if(o.getClass().equals(A2.class)) {
            return a.equals(((A2)o).a);
        } else {
            return false;
        }
    }
}

class B2 extends A2 {
    private String b;
    public B2(String a, String b) {
        super(a);
        this.b = b;
    }
    public String getB() {
        return b;
    }
    public void setB(String b) {
        this.b = b;
    }
}
