Google+

212. Default Package







Classes in Java need to be created under any packages. In case, if we don't provide any package name while creating a Class, Java automatically creates the Class under a package called 'Default Package'.

Lets create a Class in a Java Project without creating a Package prior to it and find out what Java does.

Lets implement on Eclipse IDE -

1. Launch Eclipse IDE , Create a new Java Project 'Project 40' and observe that no packages are displayed before creating Class as shown below -


2. Now create a Class 'ClassA' without creating a package prior to it, Java creates the Class under the default package as shown below -


 Hence Java automatically creates the package 'default package' when Class is created without creating any package.





Please comment below to feedback or ask questions.

Creating Hierarchy of Packages will be explained in the next post.







No comments: