Is the use of Java’s default package a bad practice?

Yes, it is. Ideally, package names should be globally unique, to avoid naming collisions. Using the default package breaks this convention. It’s also impossible to import a class from the default package.

Why do unnamed packages exist at all, if it’s such a bad idea? From the JLS ยง7.4.2:

Unnamed packages are provided by the Java platform principally for convenience when developing small or temporary applications or when just beginning development.

Leave a Comment