As @Sanjeevan is using Eclipse, here is a way to nest packages in Eclipse;
root folder
of your desired "nested" package branch,New > Folder
, finish
(in this example, the name of the first folder is parent
),parent
folder.New > Folder
, finish
(in this example, the name of the second folder is child
),parent.child
. This is your nested "package". When you create a new class under this folder, either package parent.child;
will be added automatically to the top of your classes, or you must add them manually.The solution was to type the sub packages with a '.' So if we have a main package say 'com.main' and we wanted to make sure we wanted to create a sub package for that we should write it as 'com.main.sub'
and to make sure we have it visually follow that, you can read this. https://stackoverflow.com/a/25378808/20406462
The layout of the packages on disk is standardized, it's not something you can change, and it's the same whether you're using javac
, IDEA, Eclipse, or anything else. They are always nested. What you're looking for is how to change they way they're shown to you.
Change the Package Presentation setting in the View to Hierarchical .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.