File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes default package related query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "default package related query" Watch "default package related query" New topic

default package related query

Poorvika Chandra

Joined: Jun 27, 2011
Posts: 3
Dear all,

As we know it is not recommended to write classes under default package.Then what might be the purpose behind the introduction of default packages in java

Ogeh Ikem
Ranch Hand

Joined: May 13, 2002
Posts: 180
You can compile and run a class in a default package (just like any other class). The only problem is that you cannot import the default package.
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4624

The purpose of the default package is to enable people to quickly write very small test programs or example code, without cluttering it with the package declaration.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
And welcome to the Ranch
Poorvika Chandra

Joined: Jun 27, 2011
Posts: 3
I agree. Here's the link:
subject: default package related query
It's not a secret anymore!