• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

doubt in page 774 and 775 of K& B book

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Remember when using a classpath, the last directory in the path must be the super-directory of the root directory for the package.
When you use an import statement you are declaring only one package.
When you say import java.util.*; you are saying "Use the short name for all of the
classes in the java.util package." You�re NOT getting the java.util.jar classes or
java.util.regex packages! Those packages are totally independent of each other; the
only thing they share is the same "root" directory, but they are not the same packages. As
a corollary, you can�t say import java.*; in the hopes of importing multiple packages
�just remember, an import statement can import only a single package.


Can any one explain me the the meaning of above lines or can give me example.
Thanks in advance.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
root/
root/java/
java/util/
-Date.class // import java.util.Date
-Calendar.class // import java.util.Calendar
// both can be imported by import java.util.*
java/util/regex/
-Pattern.class //import java.util.regex.Pattern
//or import java.util.regex.* to import all under regex folder
java/lang/

Note: import java.util.* will NOT import regex folder classes at all but just CLASSES (not subpackages) under util package/folder.
[ August 07, 2007: Message edited by: ajay futuro ]
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Divya,

it says, that the import statement doesn't include classes from nested packages. The following code will not compile since
java.util.*
is included and not
java.util.jar.*
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explaination . I got it
reply
    Bookmark Topic Watch Topic
  • New Topic