[英]Java: IntelliJ idea generated code incorrectly prefixing all Class designations with their Package name
I have a package 'World', containing a class 'World' and a class 'Tile'. 我有一个“世界”包,其中包含一个“世界”类和一个“瓷砖”类。 Class World contains an array of Tiles.
Class World包含一组Tiles。 When I use IDEA's Generate Constructor function, it produces a constructor like this:
当我使用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.
它按预期工作。
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.
我正在运行新的IDEA安装,以前从未遇到过此问题,但是我认为我没有更改任何可能导致此问题的内容。 Apologies if this has been asked before I tried searching every permutation of words I could think of!
很抱歉在我尝试搜索我能想到的单词的所有排列之前都问过这个问题!
World Class before constructor is added: 添加构造函数之前的世界一流:
package World;
public final class World {
private final int width;
private final int height;
private final Tile[][] terrain;
}
Obicere's comment: Obicere的评论:
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! 软件包名称可能会遮蔽类名称-使用小写的软件包名称!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.