Java field type for a value of a generically recursive self-type?

前端 未结 1 1834
故里飘歌
故里飘歌 2021-01-14 00:39

Given a class hierarchy where the base class defines a recursive self-type:

abstract class A> { }

How can I decl

1条回答
  •  忘掉有多难
    2021-01-14 00:57

    If you bound the wildcard ? below by A, it should work:

    public class B {
        private A a;
    
        public > void setA(T a) {
            this.a = a;
        }
    }
    

    0 讨论(0)
提交回复
热议问题