• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Default Package

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a package name is not specified for the class, the class
will be placed in a "default" package.
Where does this default package reside and what does it contain?
Is it garbage collected?

Any help is greatly appreciated.
Thank you.
-Jay
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no its just a package like the others. if u dont put a package definition in a code, the classes in this file will be thrown into the default package. this package contains all classes like this.so classes which are not specified with a package are treated as in same package, the default package.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Packages are not garbage collected. Objects are garbage collected.
 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jay Kay:
If a package name is not specified for the class, the class
will be placed in a "default" package.
Where does this default package reside and what does it contain?
Is it garbage collected?
Any help is greatly appreciated.
Thank you.
-Jay


Hi Jay
Great boss has given answer for garbage collection.. so no more words after that..
The default package is your directory where you are placing your class file.
So what is the need of package??
If I want to use your class then I have place my .java file in the same folder where is your class file else i won't be able to use that class. And also if i want to run your file then again i have to go to your directory where u have placed class file.
package is a way to arrange your classes, to make easier access and to avoid name collision, as directory structure is to arrange your files. (when i was novice then i used to think what is the use of CD, MKDIR (dos commands), why to make directory? now on my disk by the directory name i can tell which files willbe there. so it takes time... to understand proper use of some good things)
CMIW
------------------
Regards
Ravish
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could consider that there is default package in each directory in which a Java application is launched. This package contains all the Java classes that reside in this directory and their sources has no package sentence.
In each directory also a named package could exist.
Please use the default package only for litle programs that you are not going to distribute or testing litle programs.
Please never tries to mix both types of packages, though possible it is of no use at all.
Remember that Sun encourages us to use named packages for any real program.
 
Jay Kay
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Awesome. Thanks guys.
-Jay
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic