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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:45:51+00:00 2026-06-04T04:45:51+00:00

If I have an Enum as a helper in a Java class, is there

  • 0

If I have an Enum as a helper in a Java class, is there any way to refer to that Enum outside of the class it’s helping?

Basically, what I have is this:

class Account extends MyClass {
    HashMap<Property, String> property = new HashMap<Property, String>();
    public Account() {
    }

    public enum Property {
        USERID,
        PASSWORD;
    }
}

I want to be able to access the Property enum outside of the Account class.

The reason I want to do this is because this is a subclass of a another, and I want to be able to access the properties of a given subclass without referring to a unique enum name (i.e.: without referring to each one as, say, AccountProperty or ResearchProperty or TaskProperty etc).

  • 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-04T04:45:52+00:00Added an answer on June 4, 2026 at 4:45 am

    Your enum is public so you just can use Account.Property to access it from outside the Account class

    EDIT :

    If I got what you need, you’d like to do something like

    Property p = Account.Property.PASSWORD;
    Property p1 = Product.Property.CODE;
    

    where Product is

    public class Product extends MyClass{
        HashMap<Account.Property, String> property = new HashMap<>();
        public Product() {
        }
    
        public static enum Property {
            CODE,
            PRICE;
        }
    }
    

    and you want to do this in your MyClass.

    The problem is that both the two lines require an import and you can’t import two classes with the same name, so the only solution is to do something like this

    Account.Property p = Account.Property.PASSWORD;
    Product.Property p1 = Product.Property.CODE;
    

    I guess that you’ve got to deal with the instanceof to use the right Property enum for each class, as there’s no way to extend an enum!

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

Sidebar

Related Questions

I have the following methods in an enum helper class (I have simplified it
I have a handful of helper methods that convert enum values into a list
I'm writing a project in c# asp.net mvc3, and I have a helper-class that
I have an enum defined in the Constants.h file this way: typedef enum {
I have enum like this [Flags] public enum Key { None = 0, A
I have enum like this: public enum ObectTypes { TypeOne, TypeTwo, TypeThree, ... TypeTwenty
I have an enum type like this as an example: public Enum MyEnum {
I'm looking for a way to have Enum a => UArray a (which makes
I have the following helper method in a ViewModelBase class, which is inherited by
Pretty new to threading and I have this QList that the threads share between

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.