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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:29:36+00:00 2026-06-09T16:29:36+00:00

I was helping a friend with Java the other day, and they were asking

  • 0

I was helping a friend with Java the other day, and they were asking about Enums. I explained that the C syntax of (something like)

enumeration Difficulty{
    BEGINNER= 1;
    PRO=5;
    EXPERT = 11;
}

Wasn’t the way to go, the Java syntax is something(1); you made a constructor that accepted an int and then did this and that…etc.

But they stopped me and asked “If we’re using constructors and so on, why bother with an enum, why not just have a new class?”

And I couldn’t answer. So why would you use an enum in this case, and not a class?

  • 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-09T16:29:37+00:00Added an answer on June 9, 2026 at 4:29 pm

    Enums are strictly limited. It is impossible to define an enum value outside of the specified values (whereas with a class you can invoke new to create a new value).

    Enums are also heavily optimized by at least most JVMs, and there are also new classes and language features which take advantage of enums’ compactness and speed. For example, there are new classes created, EnumSet and EnumMap, which implement an enum-keyed set or map using a bitset and an array, respectively (which are probably the fastest possible implementations for those abstract data types).

    Additionally, enum types can be used in switch statements. If you’re pre-Java1.7, this is your best option for customized switch statements (and is still probably superior to using String values because of type safety; mistyping the enum value will cause a compile-time error, but mistyping the string will cause a more insidious runtime error– or worse, a logic error that you can’t understand until you really stare at the code and see the typo).

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

Sidebar

Related Questions

I'm helping a friend with a java problem. However, we've hit a snag. We're
I was helping a friend to write some Java code, who doesn't know a
I was helping a friend with some C++ homework. I warned said friend that
I'm helping a friend do a little jquery, and along with that is some
I'm helping a friend learn Haskell and he recently created code like this, which
Right now I am helping a friend flesh out an idea about displaying various
Helping a friend with his new tumblr blog. Anyway I preface this with that
I am helping a friend from first year to prepare his exam on Java.
Yesterday I was helping a friend to compile Intel's MKL Java examples. We were
I'm helping a friend create an android app that will have screens with lists

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.