This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about packages

 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please explain the concept of packages with a program
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at this Wikipedia article.
[ August 19, 2006: Message edited by: Scott Johnson ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darn, that Wikipedia guy is pretty smart!

I don't think they talked about the practical uses, though. There are several good reasons to use packages ...

1) To organize files on your source directories and in your head. On disk package are usually just folders, so we organize code in some way that makes sense to us just like we organize documents and pictures and other files.

2) To bundle up parts of the system with different characteristics. For example Robert Martin suggests we package abstract classes that don't change very often together, and concrete classes that change a lot together.

3) To set up units of deployment or distribution. If I have a neat utility I want to share with you, it's ideal if I can give you a jar with exactly the classes you need, no more and no less. Or if I have a big system I might want to update the user interface on my production server without touching the database accessors. We can set up packaging and jars just for that.

#2 and #3 can get a bit advanced for this forum, so don't sweat it if they didn't make much sense. Use #1 to organize code and get used to the mechanics of how to import and such. The other stuff will come when you need it.
 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know that how to compile when package statement is
there in a program.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15435
41
Android IntelliJ IDE Java Scala Spring
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic