-1

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

I am beginning to code Java in Eclipse. I created a new project and noticed a default package.

What is the benefit of creating a new package (via right-clicking "src") and naming it say "com.johnhoffman.myproject"? My application seems to work just fine with the default package.

Community
  • 1
  • 1
John Hoffman
  • 17,857
  • 20
  • 58
  • 81

1 Answers1

0

Why create your own package:

Organisation, If you put everything in the default package, after a few years you would have several thousand classes in the default package and finding anything would be just about impossible. It would make naming a new class difficult - you would need to check if the name was already used.

Reuse by others If everyone put everything in the default package, how would you distinguish between your layout class and johns layout class and peters layout class

I would try and give your package a sensible name - helps If you need to refer back to the code later.

i.e.
    shop.swing.exercise
rather than
    exercise1

also see

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

Community
  • 1
  • 1
Bruce Martin
  • 10,358
  • 1
  • 27
  • 38