You need to specify the enum class along with the enum constant:
It does not actually matter that you're passing it to a constructor. This must be done practically wherever enum constant is used.
Joined: Apr 15, 2011
Telling me AutoType can't be resolved. I have seen examples without the period. What is the period doing? When would a period be correct and why would examples show a space? Does it have something to do with the method being in the same class or being in an instanceof? I hope I am using the right verbiage.
Niccola LeBaron wrote:Telling me AutoType can't be resolved.
You've probably got more than one package in your project. If so, you need to import the AutoType enum into the source file using the import statement. Read this tutorial on packages and come back if anything is not clear.
I have seen examples without the period. What is the period doing? When would a period be correct and why would examples show a space?
The period serves to reference a field that is part of some class or instance, or (alternatively) to separate class name from package specification. In your case, the SUV constant is part of the AutoType class (enum is just a little bit special class in Java - find out and read Java tutorials on enums if you're not sure why SUV is a constant or how is it part of the AutoType class).
If you use enum in a switch statement, you don't have to specify the enum class in individual case statements inside the switch - the class is unambiguously determined by the type of the expression in the switch statement.
There is a way to avoid the need to specify class name in other statements too (the import static statement). However, I'd suggest you to ignore it now and revisit it once you get better grasp of the more basic Java concepts.
Does it have something to do with the method being in the same class or being in an instanceof?
Yes. Statements in a method of a class do not have to qualify the same class or its super classes with name - it is inferred automatically from the context.
The instanceof is somewhat connected to this concept as it tests whether an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.