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 7835073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:28:02+00:00 2026-06-02T13:28:02+00:00

Can I create an enum (constants to use in a switch statement) from two

  • 0

Can I create an enum (constants to use in a switch statement) from two enums???

Something like…

public class Test{

    public enum WorkDay {Monday, Tuesday, Wednesday, Thursday,Friday};
    public enum WeekEndDay {Sunday, Saturday};

    // it doesn't work ):
    public enum Day{WorkDay.values(),WeekEndDay.values()}; 

    public static void Action(Day d) {

        switch(d){
            case Monday:
                ...;
                break;
            case Tuesday:
                ...;
                break;
            case ...:
                ...;
                break;
            case Saturday:
                ...;
                break;
        }
    }
}

Any idea??? I really want to use switch and have separated the enums
Thanks!!!

  • 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-06-02T13:28:08+00:00Added an answer on June 2, 2026 at 1:28 pm

    No. You could create a Day enum and explicitly list each value, providing a constructor for each type as well… but personally I’d use:

    public enum Day {
        MONDAY(true),
        TUESDAY(true),
        WEDNESDAY(true),
        THURSDAY(true),
        FRIDAY(true),
        SATURDAY(false),
        SUNDAY(false);
    
        private final boolean workDay;
    
        private Day(boolean workDay) {
            this.workDay = workDay;
        }
    
        public boolean isWorkDay() {
            return workDay;
        }
    }
    

    You could then also publish an EnumSet<Day> for work days and another for non-work days.

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

Sidebar

Related Questions

In Java, you can create an enum as follows: public enum Letter { A,
I wish to create an enum-like list of constants with the following properties: The
How can create a view with mutiple images, something similiar to the photo app
I'd like to create an instance of a class using unity where the class
I would like to create a function that contains all text and constant. From
Using extension method we can create methods to convert an enum to other datatype
I want to create an enum-like set of strings in a way that will
I have a collection of objects like so: public enum ObjectType { Type1, Type2
I have this class constructor AppData(Map params, Operations operation) where Operations is public enum
I've encourted a problem recently about cycling between constants of an enum class in

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.