Reputation: 4043
Why is it not recommended to use default package in JAVA? Though I understand it makes more sense to have a more reasonable and descriptive package names for maintainability and readability purposes, but are there any other reasons behind it?
Upvotes: 2
Views: 1059
Reputation: 6057
Truthfully, it depends. If you are writing tests, or useless code it does not matter. As mentioned above namespace collision is important. Some API's, such as Android and Bukkit require package names.
Upvotes: 1
Reputation: 41188
Package naming conventions are to prevent namespace collisions.
If you create a class called "Test" and thousands of other people also create classes with that name because you are using different package names they don't clash.
If you never publish your code it's not such a big deal but if you ever release a library you need to use proper packages. Even for your own projects it takes very little time to do it properly so it's best to get into good habits early.
Upvotes: 8