wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes package statement and import statement difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package statement and import statement difference?" Watch "package statement and import statement difference?" New topic
Author

package statement and import statement difference?

Krystal Tyler
Greenhorn

Joined: Feb 03, 2002
Posts: 4
I am a beginner and I still can't rule out what is the difference between what a package statement does and an import statement.
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
I just want to give a example
package is just like a bag. Where you place items.
say you have placed some books, pen, pencil etc in a bag.
here books,pen,pencil are java code.
now even i have a bag with same/different items and assume both of our bags are placed next to each other.
A third party want to make use of your items. How do he refer's.
For that he calls your bag name with item he wants to use. for this to happen he uses "import" .
package is to define your bag name. And import is to use the content of the bag.
Hope this help. All the best
-arun


Sharing is learning
Krystal Tyler
Greenhorn

Joined: Feb 03, 2002
Posts: 4
Thank you for analogy. I understand now!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: package statement and import statement difference?