I have a package 'World', containing a class 'World' and a class 'Tile'. Class World contains an array of Tiles. When I use IDEA's Generate Constructor function, it produces a constructor like this:

我有一个'世界'包,包含一个'世界'类和一个'Tile'类。 Class World包含一系列Tiles。当我使用IDEA的Generate Constructor函数时,它会生成如下构造函数:

World(int width, int height, World.Tile[][] terrain) {
    this.width = width;
    this.height = height;
    this.terrain = terrain;
}

It immediately highlights "Tile" red and says it can't find that symbol. When I remove the "World." it works as expected.

它立即突出显示“Tile”红色,并表示无法找到该符号。当我删除“世界”。它按预期工作。

What've I screwed up here? I'm running a new installation of IDEA and I've never had this issue before, but I don't think I changed anything that should be causing this. Apologies if this has been asked before I tried searching every permutation of words I could think of!

我搞砸了什么?我正在运行IDEA的新安装,我之前从未遇到过这个问题,但我认为我没有改变任何导致此问题的内容。在我尝试搜索我能想到的每一个单词的排列之前,如果有人问过这个问题,我深表歉意!

World Class before constructor is added:

添加构造函数之前的World Class:

package World;

public final class World {

    private final int width;
    private final int height;

    private final Tile[][] terrain;

}

1 个解决方案

#1


Obicere's comment:

The World class is most likely shadowing the World package. By standard, this is why you use lowercase packages and upper-camel-cased class names.

世界级很可能会影响世界一揽子计划。按照标准,这就是你使用小写包和上层驼峰类名的原因。

Package names can shadow class names--use lowercase package names!

包名称可以影响类名称 - 使用小写包名称!

更多相关文章

  1. 自定义MapReduce输入格式 - 找不到构造函数
  2. 关于webview中java调用js函数(解决loadUrl函数没反应)
  3. 使用Java中的Scala:将函数作为参数传递
  4. 关于Javascript中声明变量、函数的笔记
  5. 异步执行多个任务并在JavaScript函数中返回第一个成功的结果

随机推荐

  1. android studio 报Error:failed to find
  2. 环境变量ANDROID_SDK_HOME的作用
  3. android控件之ImageButton android:scale
  4. android布局居中
  5. android:各种访问权限Permission
  6. android消息处理机制学习(一)-Handler,Mess
  7. android 二 BMI 小例子
  8. Android 3.0 r1 API中文文档(107) —— A
  9. android aapt (android asset packaging t
  10. [置顶] Android 5.1 open data flow 数据