[英]How can I have 2 files of the same name in an eclipse project but in 2 different sub-folders?
Right now I have a set up like this: 现在我有这样的设置:
...\\lab18\\18a\\18a.java ... \\ lab18 \\ 18A \\ 18a.java
...\\lab18\\18a\\monster.java ... \\ lab18 \\ 18A \\ monster.java
and 和
...\\lab18\\18b\\18b.java ... \\ lab18 \\ 18B \\ 18b.java
...\\lab18\\18b\\monster.java ... \\ lab18 \\ 18B \\ monster.java
the issue is the 2 'monster.java' files in the 18a and 18b sub-folders, is there a way to keep these names the same but not cause errors on the 'monster.java' in the 18b, 18c, etc sub-folders? 问题是18a和18b子文件夹中的2'yarge.java'文件,有没有办法保持这些名称相同但不会导致18b,18c等子中'monster.java'的错误文件夹? The error eclipse is stating is that
Monster
is already defined referencing to the .java file in the 18a folder. 错误eclipse说明
Monster
已经定义为引用18a文件夹中的.java文件。
here is a screenshot of what I'm referring to: 这是我所指的截图:
Here is a screenshot of how the files and folders are organized in Windows explorer: 以下是Windows资源管理器中文件和文件夹的组织截图:
Same source folder, two packages: 相同的源文件夹,两个包:
Package declaration in the Java classes Java类中的包声明
-> Same project, same source folder, different packages, same class name. - >相同的项目,相同的源文件夹,不同的包,相同的类名。
You have put them into the same package (default package) within two different source folders. 您已将它们放在两个不同源文件夹中的同一个包(默认包)中。 The only way you will be able to have two classes with the same name is if they are in different packages.
只有两个类具有相同名称的唯一方法是它们位于不同的包中。
For example, for lab18 one, put it into a subfolder called lab 18a and put lab18b into a subfolder called lab18b 例如,对于lab18 one,将其放入名为lab 18a的子文件夹中,并将lab18b放入名为lab18b的子文件夹中
lab18_oop_interfaces
lab18a
lab18a
Lab18a.java
Monster.java
lab18b
lab18b
Lab18b.java
Monster.java
Alternatively, put both the subfolders into one src folder and mark that as the source folder: 或者,将两个子文件夹放在一个src文件夹中,并将其标记为源文件夹:
lab18_oop_interfaces
src
lab18a
Lab18a.java
Monster.java
lab18b
Lab18b.java
Monster.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.