Did you know that classes in the ‘default package’ (classes that don’t have a package) cannot be imported from classes that do have a package?
I did not know that.
Try it:
Now try to compile your code:
>javac Class1.java
>javac package2\Clazz2.java -cp .
package2\Clazz2.java:3: ‘.’ expected
import Class1;
^
package2\Clazz2.java:3: ‘;’ expected
import Class1;
How stupid is this?
Is this why omitting package is deprecated?
July 13, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment