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

class A {
    private String a;
    public A(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 instanceof A) {
            return a.equals(((A)o).a);
        } else {
            return false;
        }
    }
}

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