Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:19:23+00:00 2026-05-27T11:19:23+00:00

If I had a class in Java like this: public class Test { //

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:19:23+00:00Added an answer on May 27, 2026 at 11:19 am

    An enum switch case label must be the unqualified name of an enum constant:

    switch (test.getStatus()) // returns the current status
    {
        case Opened:
            // do something
            // break and other cases
    }
    

    It doesn’t matter that it’s defined within another class. In any case, the compiler is able to infer the type of the enum based on your switch statement, and doesn’t need the constant names to be qualified. For whatever reason, using qualified names is invalid syntax.

    This requirement is specified by JLS §14.11:

    SwitchLabel:
       case ConstantExpression :
       case EnumConstantName :
       default :
    
    EnumConstantName:
       Identifier
    

    (Thanks to Mark Peters’ related post for the reference.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In java <1.5, constants would be implemented like this public class MyClass { public
First off I'd like to say this is the only java experience I've had.
I had a question about Java Class Path variables. If I have multiple jars
If I had generic class: public class GenericTest<T> : IGenericTest {...} and I had
I have a class that had an inline member, but I later decided that
Imagine in the Global.asax.cs file I had an instance class as a private field.
I had a winforms C# class that internally was looking up a file.. to
I had the following set-up which worked perfectly fine: @Service public class MyService {
Consider the following Java function: public void foo(Class<? extends Exception> cl, List<? extends Exception>
The story: I had class User and class Organization: User. I did not use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.