• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar files

 
ayush raj
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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?
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
Henry Wong
author
Marshal
Pie
Posts: 21184
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic