If I had a class in Java like this:
public class Test
{
// ...
public enum Status {
Opened,
Closed,
Waiting
}
// ...
}
And I had a different class in a different class file (but in the same project/folder):
public class UsingEnums
{
public static void Main(String[] args)
{
Test test = new Test(); // new Test object (storing enum)
switch(test.getStatus()) // returns the current status
{
case Status.Opened:
// do something
// break and other cases
}
}
}
I would effectively have an enum in one class that is used in another class (in my case, specifically in a switch-case statement).
However, when I do that, I get an error like:
cannot find symbol - class Status
How would I fix that?
If your
getStatus()
returns in fact aStatus
your case should be :If you try:
your IDE will give you an error like :