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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:28:35+00:00 2026-05-19T03:28:35+00:00

Consider the enum: enum day{ MONDAY, TUESDAY}; What are monday, tuesday. the sun documentation

  • 0

Consider the enum:

enum day{ MONDAY, TUESDAY};

What are monday, tuesday. the sun documentation says that they are fields in the special class type enum. But, if that is the case, why can we do:

day d=day.MONDAY  

I mean how can we assign a class constant to a class variable.

  • 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-19T03:28:36+00:00Added an answer on May 19, 2026 at 3:28 am

    Like @Jon’s suggestion but more specificly …

    EDIT: I have added some of the methods Enum provides for you. I hope that helps…

    public class Day /* extends Enum */ {
        public static final Day MONDAY = new Day("MONDAY", 0);
        public static final Day TUESDAY = new Day("TUESDAY", 1);
    
        private static final Day[] values = { MONDAY, TUESDAY };
        private static final Map<String, Day> valueOfMap = new HashMap();
    
        public static Day[] values() { return values.clone(); }
        public static Day valueOf(String name) {
            Day day = valueOfmap.get(name);
            if(day == null) throw new IllegalArgumentException(name);
            return day;
        }
    
        private final String name;
        private final int ordinal;
    
        private Day(String name, int ordinal) {
            this.name = name;
            this.ordinal = ordinal;
            valueOfMap.put(name, this);
        }
        public String name() { return name; }
        public int ordinal() { return ordinal; }
        public String toString() { return name; }
    }
    
    public class Other {
        Day day = Day.MONDAY;
    }
    

    This may not be how it is implemented but how you could implement it.

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

Sidebar

Related Questions

Consider the following Enum and a corrsponding nullable field of that type enum PossibleOptions
Please consider the following code. enum type {CONS, ATOM, FUNC, LAMBDA}; typedef struct{ enum
Consider these classes. class Base { ... }; class Derived : public Base {
Why can't enum's constructor access static fields and methods? This is perfectly valid with
Which is the appropriate (more readable) way of naming enumerator? will you consider: enum
Given an enum that has assigned values, what is the best way to get
Consider this: [Flags] enum Colors { Red=1, Green=2, Blue=4 } Colors myColor=Colors.Red|Colors.Blue; Currently, I'm
Let's consider the following enum in C# public enum ScrollMode : byte { None
Consider I have an enum, which I have coded today. What are the possible
Consider the following (simplified) code: enum eTestMode { TM_BASIC = 1, // 1 <<

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.