英文:
Is creating a package in Eclipse, equivalent of creating a new folder?
问题
我没有使用Eclipse,所以对于我的项目,当指示"创建一个名为“Project 1”的新Java项目,并将上述两个文件导入默认包。"这样做是否相当于只是把这两个文件放入一个文件夹并将其命名为"Project 1"?
因为我在使用VS Code,如果不是这样的话,我该如何在VS Code中创建一个包?
英文:
I'm not using Eclipse, so for my project when stated "create a new Java project called "Project 1", and import the above 2 files into a default package. "
Is that the equivalent of just throwing the two files into a folder and naming it "Project 1"?
Because I'm using VS Code, If not how would I be able to create a package on VS Code?
答案1
得分: 1
是的,在VS Code中关于包(package)的部分,我们首先需要做的是创建一个文件夹。
当我们在src下创建一个文件夹,假设它的名字是AAA。如果在AAA文件夹下创建了一个.java文件,在顶部一行会有一个**package AAA;
**的语句,就像截图所示:
如果**package AAA;
**没有自动生成,我们需要在每个位于这个文件夹下的文件中手动添加它。
英文:
Yes, about package in VS Code, the first thing we need to do is creating a folder.
When we create a folder under src, which we assume its name is AAA. if a .java file is created under AAA, there will be a statement package AAA;
on the top line, like the screenshot shows:
If package AAA;
isn't generated automatically, we should add it manually in every file which is under this folder.
答案2
得分: 0
一个包是位于项目目录下方的 src 目录下的子目录。使用默认包不会遇到任何问题,但通常最好的做法是将所有的类和其他文件放入一个包中,以便更有组织。
英文:
A package is a subdirectory below the src directory which is below the project directory. You won't run into any issues using the default package, but it is generally good practice to put all your class and other files into a package so it is more organized.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论