• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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
HI,

comiler by default imports 3 packages

1. default package
2.java.lang
3.current package


can anyone explain this with examle
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by srinivas bokka:
...comiler by default imports 3 packages

1. default package
2. java.lang
3. current package...


To be honest, I'm not sure I understand what this is saying. I know that java.lang is automatically imported. But wouldn't the default package only be available if it is the current package? And are these actually "imported"? Where did this information come from?
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by marc weber:

To be honest, I'm not sure I understand what this is saying. I know that java.lang is automatically imported. But wouldn't the default package only be available if it is the current package? And are these actually "imported"? Where did this information come from?



It comes from Java Tutorial:link
under the title: Importing an Entire package
 
Yeming Hu
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that the classes in default package can only be used by other classes in the default package. But they are not automatically in classes which are not in the default package.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yeming Hu:
It seems that the classes in default package can only be used by other classes in the default package. But they are not automatically in classes which are not in the default package.


That's exactly why I don't understand what this is saying. I can't demonstrate that the unnamed package is visible when the current package is named.

It's clear that java.lang is automatically imported. In addition, I would say that the current package -- which might be the unnamed (default) package -- is also imported. But I don't see that the unnamed package is automatically imported if the current package is named.

Maybe this is what the tutorial is trying to say. But I read it as telling us that all 3 of these packages are automatically imported at the same time, and I don't think that's right.
 
reply
    Bookmark Topic Watch Topic
  • New Topic