I've been struggling with my first regex. During the compile, Pattern
and Matcher
kept getting cannot find symbol
errors.
I just changed import java.util.*
to import java.util.regex.*
and it works like a dream.
I was under the impression that import
ing java.util.*
would also bring in java.util.*.*
etc. Is that not the case? I can't find any documentation that addresses this specific question....
No, package imports only get the direct classes in that package (java.* will not import everything, only ones such as Java.SomeClass, not java.util.SomeClass)
See a link and a quoted excerpt from the link below.
http://docs.oracle.com/javase/tutorial/java/package/usepkgs.html
Importing
java.util.*
will not importjava.util.*.*
.Yes, that is how package imports work (and are supposed to work) in Java. For example, doing
import javax.swing.*;
will import all classes withinjavax.swing.*
but not sub-packages and their classes.Ergo,
javax.swing.*
will not importjavax.swing.event
orjavax.swing.event.*
Read the following blog for some friendly newbie advice.