So I'm facing a cannot find symbol error when static importing an enum in a class that depends on it. They are both in separate files within the same directory. I've omitted an explicit package name.
TokenType.java
// No imports
enum TokenType {
ADD, MINUS, MULTIPLY, DIVIDE,
...
}
Scanner.java
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import static TokenType.*; // <--- (error: cannot find symbol)
class Scanner {
private static final Map <String, TokenType> keywords; // <--- (no error; javac can resolve the class name just fine)
static {
keywords = new HashMap<>();
keywords.put("+", ADD); // <-- (error: cannot find symbol, which makes sense)
keywords.put("-", MINUS);
...
}
...
}
I'm just not sure how to proceed. The names are all typed correctly, and there is only one TokenType class so there isn't a class conflict. My other classes in the project directory have no nested classes, do not extend/implement from other classes, or import libraries that have a TokenType class in their dependencies. I've cleaned my directory of all stale classes before each compile, and even changed the order in which I'm calling javac. Any help would be wonderful, thank you.
EDIT: Solution was to put them in a named package. Java doesn't allow imports from default package.