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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:39:33+00:00 2026-05-18T00:39:33+00:00

My suggestions: 1) either enum s exist only before compilation (like generics; but I’ve

  • 0

My suggestions:

1) either enums exist only before compilation (like generics; but I’ve never heard anything about it whilst it’s written everywhere that generics are being erased after compilation)

2) or Enum is a way to maintain backward compatibility in some way (but I don’t see that way yet).

Any other suggestions? (btw, have you ever used it in your code?)

UPD: http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Enum.html

In other words, there’s a enum keyword and Enum class. They both appeared in Java 5. The question: why do we need both?

The second question: why Enum became a part of the API?

  • 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-18T00:39:33+00:00Added an answer on May 18, 2026 at 12:39 am

    From the Java Tutorials:

    You should use enum types any time you need to represent a fixed set of constants. That includes natural enum types such as the planets in our solar system and data sets where you know all possible values at compile time—for example, the choices on a menu, command line flags, and so on.

    Enums are extremely useful, and yes, I have used them plenty of times in my code.


    Edit:

    …there’s a enum keyword and Enum class. They both appeared in Java 5. The question: why do we need both?

    This question is analogous to asking “there’s a class keyword and an Object class. Why do we need both?”

    In both cases, the keywords are basically hints to the compiler; you could think of them as syntactic sugar that saves you keystrokes, and lets the compiler do less work (by not making it guess about what you’re declaring).

    See this q&a as well.

    …have you ever used it in your code?

    The answer is still “yes.” In particular, Enum#valueOf() is a static method useful for parsing strings:

    DayOfWeek d = Enum.valueOf(DayOfWeek.class, "TUESDAY");
    

    but of course this works, too:

    DayOfWeek d = DayOfWeek.valueOf("TUESDAY");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any suggestions on the best way to ensure thread safety when changing the properties
Any suggestions? Using visual studio in C#. Are there any specific tools to use
Any suggestions for good open source asp.net (C#) apps out there which meet as
Any suggestions on how to write repeatable unit tests for code that may be
Any suggestions on how to improve DataGridViewComboBoxColumn performace with large item sets? I've got
Any suggestions for an accurate Web Log analysis tool to generate reports on the
Does anyone have any suggestions on how to mentor a junior programmer ? If
Any good suggestions? Input will be the name of a header file and output
Looking for suggestions on file system management tools. We have several terabytes of images,
What are some suggestions for easy to use C++ compilers for a beginner? Free

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.