dimanche 8 juillet 2018

Why this program has not-expected output?

package ir.openuniverse;

public class Main {
    public static void main(String[] args) throws NoSuchFieldException {
        System.out.println(A.class.getField("t").getType().getName());
    }
}

class A extends B<D> {}
class B<T extends C> {
    public T t;
}

class C {}
class D extends C {}

The output is ir.openuniverse.C. Why? I expect D!





Aucun commentaire:

Enregistrer un commentaire