I was trying to use use static imports on Java, but I was writing it wrong
static import java.lang.System.out;
And the code compiled (although the “out” symbol couldn’t be found), no syntax errors.
So, what does the “static import” actually means?
This should not compile.
According to the JLS, a single static import should look like this:
All forms of the Java import statement start with the
importkeyword, and I don’t think there is any other context (i.e. apart from an import statement) in which theimportkeyword can be used.Note: the
importandstatickeywords are not modifiers in this context, so the “modifiers can be supplied in any order” meta-rule does not apply here.In short, either your compiler / IDE is broken or confused … or what you are looking at is not real Java source code.