1

该类是通用的,假设 Generic<T>它包含以下内容:

private int count;
public int Count()
{
  return count;
}

它有一个引发编译器错误的方法。它找不到类的符号Count()(或countGeneric<capture#940 of ? extends T>并指向这些行:

public void set(Generic<? extends T> other)
{
  int something = other.Count();
  int somethingElse = other.count;
  //actions
}

为什么在 中找不到符号other?我把它放在那里。此外,有关如何标记此问题的任何提示。我无法弄清楚如何将它与包范围、类调用、子类化、委托、命名空间等问题区分开来。没有人使用过“找不到符号”。

4

1 回答 1

1

这是一个扩展评论,而不是答案。

以下程序在 Eclipse 中编译没有错误:

public class Generic<T> {
  private int count;
  public int Count()
  {
    return count;
  }
  public void set(Generic<? extends T> other)
  {
    int something = other.Count();
    int somethingElse = other.count;
  }
}

Please add more information. If my program does not compile in your environment, you should post information about the compile. If my program does compiler, you could post a Short, Self Contained, Correct, Example that reproduces the problem.

于 2012-12-15T03:46:15.753 回答