Is this what the Java package import is supposed to use?

I struggled with my first regular expression. During compilation, Pattern and Matcher continued to receive errors cannot find symbol .

I just changed import java.util.* To import java.util.regex.* And it works like a dream.

I got the impression that import ing java.util.* java.util.*.* also bring java.util.*.* Etc. Is not it? I can not find the documentation that will solve this particular issue ....

+3
source share
4 answers

Yes, this is how package import works (and should work) in Java. For example, when you execute import javax.swing.*; all classes in javax.swing.* will be imported, but not subpackages and their classes.

Ergo, javax.swing.* Will not import javax.swing.event or javax.swing.event.*

Read the following blog for tips on friendly newbies.

+3
source

No, package import receives only direct classes in this package (java. * Will not import everything, only such as Java.SomeClass, not java.util.SomeClass)

+9
source

Import java.util.* Will not import java.util.*.* .

+5
source

See the link and citation from the link below.

http://docs.oracle.com/javase/tutorial/java/package/usepkgs.html

Import java.awt. * imports all types into the java.awt package, but it does not import java.awt.color, java.awt.font or any other java.awt.xxxx. If you plan to use classes and other types in java.awt.color, as well as in java.awt, you should import both packages with all their files:

 import java.awt.*; import java.awt.color.*; 
+2
source

All Articles