Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Static import

843789Apr 19 2009 — edited Apr 19 2009
Why does the following mock code fail to compile?
Its not a real problem just an annoyance.
import static b.str;
public class a{}
public class b{
	public static String str = "static";
}
gleesog4@minerva (..html/rss2/src/test) -> javac b.java                 [20:53]
gleesog4@minerva (..html/rss2/src/test) -> javac a.java                 [20:53]

a.java:1: cannot find symbol
symbol: class b
import static b.str;
              ^
a.java:1: static import only from classes and interfaces
import static b.str;
^
2 errors
Ger.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2009
Added on Apr 19 2009
4 comments
401 views