Java中的内部类/内部接口如何引用外部类的类型参数T?
黄舟
黄舟 2017-04-17 13:13:40
0
2
905

例如:

public class A<T> {

    public interface I<T> {
        //...
    }

    //...

}

想在内部接口I中引用同一个类型参数T,如果做到?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
伊谢尔伦

Look at this
http://stackoverflow.com/questions/10963601/java-generics-non-static-type-variable-t-cannot-be-referenced-from-a-static-con

What you want may not be achievable. The key is to see what your purpose is and then think of individual ways to solve the problem.

迷茫

The T in this internal interface has nothing to do with your outer T. You just need to specify the same type when using it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template