【问题标题】:Example of "Type parameter hides another type" warning in EclipseEclipse 中“类型参数隐藏另一种类型”警告的示例
【发布时间】:2011-03-02 21:13:21
【问题描述】:

如何触发 Eclipse 给我“类型参数隐藏另一种类型”警告?我正在寻找代码示例。

文档是这样描述的:启用后,如果内部类的类型参数隐藏了外部类型,编译器将发出错误或警告。

【问题讨论】:

    标签: java eclipse


    【解决方案1】:
    class Test<A> {
      class Inner<A> {
        // here A denotes the generic parameter of Test.Inner
        // the type A of Test is hidden
      }
      <A> void test() {
        // here it is not a class but the type parameter A of Test is also hidden
        // if I remember well, the warning shows these too
      }
    }
    

    【讨论】:

      【解决方案2】:
      class Outer<T> {
          class Inner<T> {}
      }
      

      【讨论】:

        【解决方案3】:
        public class Outer<T>
        {
          class Inner<T>
          {
        
          }
        }
        

        【讨论】:

          猜你喜欢
          • 2021-12-24
          • 2014-06-27
          • 2011-10-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-14
          • 2014-06-23
          • 2014-10-12
          相关资源
          最近更新 更多