File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "jar files" Watch "jar files" New topic
Author

jar files

ayush raj
Ranch Hand

Joined: Jan 15, 2012
Posts: 60
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?
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 249

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


Astha - OCPJP 6 (90%)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar files