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

后端 未结 6 1266
感情败类
感情败类 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:36

    The main reasons I can think of are:

    1. It keeps things organised, which will help you (and others!) know where to look for classes/functionality.
    2. You can define classes with the same name if they are in different packages.
    3. Classes/etc in the default package cannot be imported into named packages. This means that in order to use your classes, other people will have to put all their classes in the default package too. This exacerbates the problems which reasons 1 & 2 solve.

提交回复
热议问题