jQuery in Action, 2nd edition
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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: 3658

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.
Campbell Ritchie

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

Joined: Jun 27, 2011
Posts: 3
rocket mass heater kickstarter
subject: default package related query