Why shouldn't we use the (default)src package?

后端 未结 6 1268
感情败类
感情败类 2020-12-21 08:08

I recently started using Eclipse IDE and have read at a number of places that one shouldn\'t use the default(src) package and create new packages.
I just wanted to know

6条回答
  •  无人及你
    2020-12-21 08:33

    Using the default package may create namespace collisions. Imagine you're creating a library which contains a MyClass class. Someone uses your library in his project and also has a MyClass class in his default package. What should the compiler do? Package in Java is actually a namespace which fully identifies your project. So it's important to not use the default package in the real world projects.

提交回复
热议问题