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

The Archive Base Latest Questions

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

I’m just now realizing their power and utility over using a Constants class… but

  • 0

I’m just now realizing their power and utility over using a Constants class… but I’m very interested to know how they’re implemented under the hood. They seem to work alot like a static method or static constant in that you just import the file that “owns” the enum and you can make reference to them by using enumName.valueName. The Javadocs online seem to suggest they’re a class but it seems weird to have an “unnamed” class on demand. (In Java at least…)

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

    i believe each instance of the enum is an anonymous final subclass of the enum.

    decompile:

    public enum Color {
        r(0xff0000), g(0x00ff00), b(0x0000ff);
        Color(int rgb) {
            this.rgb=rgb;
        }
        final int rgb;
    }
    

    and you can see the instances being made:

    D:\home\ray\dev\indigoapps\so8032067enumimpl\bin>javap -c Color
    Compiled from "Color.java"
    public final class Color extends java.lang.Enum{
    public static final Color r;
    
    public static final Color g;
    
    public static final Color b;
    
    final int rgb;
    
    static {};
      Code:
       0:   new     #1; //class Color
       3:   dup
       4:   ldc     #16; //String r
       6:   iconst_0
       7:   ldc     #17; //int 16711680
       9:   invokespecial   #18; //Method "<init>":(Ljava/lang/String;II)V
       12:  putstatic       #22; //Field r:LColor;
       15:  new     #1; //class Color
       18:  dup
       19:  ldc     #24; //String g
       21:  iconst_1
       22:  ldc     #25; //int 65280
       24:  invokespecial   #18; //Method "<init>":(Ljava/lang/String;II)V
       27:  putstatic       #26; //Field g:LColor;
       30:  new     #1; //class Color
       33:  dup
       34:  ldc     #28; //String b
       36:  iconst_2
       37:  sipush  255
       40:  invokespecial   #18; //Method "<init>":(Ljava/lang/String;II)V
       43:  putstatic       #29; //Field b:LColor;
       46:  iconst_3
       47:  anewarray       #1; //class Color
       50:  dup
       51:  iconst_0
       52:  getstatic       #22; //Field r:LColor;
       55:  aastore
       56:  dup
       57:  iconst_1
       58:  getstatic       #26; //Field g:LColor;
       61:  aastore
       62:  dup
       63:  iconst_2
       64:  getstatic       #29; //Field b:LColor;
       67:  aastore
       68:  putstatic       #31; //Field ENUM$VALUES:[LColor;
       71:  return
    
    public static Color[] values();
      Code:
       0:   getstatic       #31; //Field ENUM$VALUES:[LColor;
       3:   dup
       4:   astore_0
       5:   iconst_0
       6:   aload_0
       7:   arraylength
       8:   dup
       9:   istore_1
       10:  anewarray       #1; //class Color
       13:  dup
       14:  astore_2
       15:  iconst_0
       16:  iload_1
       17:  invokestatic    #43; //Method java/lang/System.arraycopy:(Ljava/lang/Obj
    ect;ILjava/lang/Object;II)V
       20:  aload_2
       21:  areturn
    
    public static Color valueOf(java.lang.String);
      Code:
       0:   ldc     #1; //class Color
       2:   aload_0
       3:   invokestatic    #51; //Method java/lang/Enum.valueOf:(Ljava/lang/Class;L
    java/lang/String;)Ljava/lang/Enum;
       6:   checkcast       #1; //class Color
       9:   areturn
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.