• 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

jar files

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was going through Kathy & Bert Bates book on SCJP . In the last lesson on JAR file , i found the following text :

"When you say import java.util.*;you are saying "Use the short names for all of the classes in java.util package". You are not getting the java.util.jar classes or the java.util.regex packages!"

I could not understand the last line. When these jar and regex classes/package do belong to java.util package , how come they are not imported?
 
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.util is one package, java.util.regex is another package. regex is a part of java.util as regex is its sub package(regex is created inside util). Its correct that regex is a part of util but as a different package. Thus when you import java.util, you import only java.util classes, not the classes of its sub packages. The same case is with java.util.jar
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ayush raj wrote:
I could not understand the last line. When these jar and regex classes/package do belong to java.util package , how come they are not imported?



The last line is basically saying that they don't belong to the java.util package. When you import java.util.*, you get the classes from the java.util package. It doesn't recursively import the classes from the java.util.regex or java,util.jar package -- to do that, you need to import java.util.regex.* or java,util.jar.* respectively.

Henry
 
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic