how i can dynamic downcast objects, with out instanceof statement? I reading Bruce Eckel's Thinking in Java, and there using Class, and there is such a theme, but I was not approached P.s. Sorry for my English.
public class GenericTest {
    static private interface Base {
    }
    static private class A implements Base {
    }
    static private class B implements Base {
    }
    static private class C extends B {
    }
    private List<Class<? extends Base>> types;
    private List<Base> objects;
    public GenericTest() {
        types = new ArrayList<Class<? extends Base>>();
        types.add(A.class);
        types.add(B.class);
        types.add(C.class);
        objects = new ArrayList<Base>(Arrays.asList(new A(), new B(), new C()));
        for (Base base : objects) {
            if (base instanceof A)
                test((A) base);
            else if (base instanceof C)
                test((C) base);
            else if (base instanceof B)
                test((B) base);
            for (Class<? extends Base> c : types)
                if (base.getClass().equals(c))
                    test(c.cast(base));
        }
    }
    private void test(A a) {
        System.out.println("A");
    }
    private void test(B b) {
        System.out.println("B");
    }
    private void test(C c) {
        System.out.println("C");
    }
    private void test(Base base) {
        System.out.println("Base");
    }
    public static void main(String[] args) {
        new GenericTest();
    }
}
 
     
     
    