GeeksforGeeks » Java specific Questions

Enums in Java

(2 posts)

Tags:

  1. learner
    guest
    Posted 6 months ago #

    How enums in Java are different from C++?

  2. kartik
    Moderator
    Posted 6 months ago #

    The Java type system, however, treats enumerations as a type separate from integers, and intermixing of enum and integer values is not allowed. In fact, an enum type in Java is actually a special compiler-generated class rather than an arithmetic type, and enum values behave as global pre-generated instances of that class. Enum types can have instance methods and a constructor (the arguments of which can be specified separately for each enum value). All enum types implicitly extend the Enum abstract class. An enum type cannot be instantiated directly.

    Source: http://en.wikipedia.org/wiki/Enumerated_type#Java


Reply

You must log in to post.

RSS feed for this topic