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

  • Home
  • SEARCH
  • 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 6782601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:45:47+00:00 2026-05-26T16:45:47+00:00

I truly understand that it is not able to extend any class to implement

  • 0

I truly understand that it is not able to extend any class to implement an enum, since this would mean to have multiple inheritance. But what I don’t understand is, why the enum classes, created by the compiler when using “enum” instead of “class” are final.

Is there any good reason why enums cannot be extended?

Plus: Is there any way to implement common behavior to different enums without Copy&Paste?

  • 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-26T16:45:47+00:00Added an answer on May 26, 2026 at 4:45 pm

    A very important aspect of enums is that the number or values are known at compile time (at least at compile time of the enum).

    So if you have an enum like this:

    public enum Foo {
      BAR,
      BAZ;
    }
    

    then you know that it has exactly two values: BAR and BAZ.

    If you could extend an enum then you could introduce an ExtendedFoo enum that adds QUUX. Now since ExtendedFoo would be a Foo, QUUX would suddenly be a valid Foo value. And nothing would stop you from adding any number of additional Foo values.

    This means that the compiler can no longer check if your switch covers all Foo cases. Similar static analysis steps are also no longer possible. Effectively your enum would cease to be a special type and there would be very little difference to a normal class with some pre-defined instances.

    Side note: the generated enum class is not always final: If (at least) one of your enum values has a value-specific body, then the “base” class will not be final, but the compiler will still prevent you from extending it.

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

Sidebar

Related Questions

I understand that the String class' hashCode() method is not guarantied to generate unique
I'm trying to understand trends of the languages. This might be not a real
Let say I have a class like this: public sealed class Foo { public
I don't truly understand some basic things in C like dynamically allocating array of
To be truly standards-compliant, must all functions in C (except for main) have a
I'm not asking if these are truly random. I just wanted to know if
I have an Action that requires authentication. The action method creates some records with
Are dynamic resources truly dynamic? If I define a DynamicResource, I realise that an
Don't think that I'm mad, I understand how php works! That being said. I
From what I understand: If you don't have a MEX endpoint / WSDL, your

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.