Everything is better when organized. With this in mind, we will check how to create packages using the IDE.
Besides being more organized, it is a bad coding practice to leave all classes in the same package or in the root package.
First, we will need to create a new project, so please refer to the recipes in Chapter 1, Using NetBeans Projects, for creating Java projects. When naming the project, enter
CreatingPackages. When the Projects explorer shows the
CreatingPackages project, expand the
CreatingPackages node if not yet expanded. When creating the project, it is not necessary to create a main class.
Now, we will create a package for our source code with the following steps: