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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:49:21+00:00 2026-06-02T20:49:21+00:00

I have a very specific issue that has to do with an inner class.

  • 0

I have a very specific issue that has to do with an inner class. Let me show you some sample code:

class Foo {
    MYOPTIONS temp;

    public static enum MYOPTIONS {
        OPTION1, OPTION2, OPTION3;
    } 
}

So this enumeration is inside the class Foo. Now what I want to do is set the temp variable as one of the three options, but do that outside the class Foo, let’s say from a class called External. Unfortunately I cannot have a set method to do that because External.setTemp (MYOPTIONS.OPTION1) is not valid, as the enum is not visible in class external.
So the only thing I could come up with is have three methods in class Foo:

public void setTempOption1 () {this.temp=MYOPTIONS.OPTION1;}
public void setTempOption2 () {this.temp=MYOPTIONS.OPTION2;}
public void setTempOption3 () {this.temp=MYOPTIONS.OPTION3;}

Obviously the other option is to change the enumeration and not have it as an inner class.
Are there any other options that I am missing?
Thanks

  • 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-02T20:49:22+00:00Added an answer on June 2, 2026 at 8:49 pm
    class ContainsInnerEnum {
        MYOPTIONS temp;
    
        public enum MYOPTIONS {
            OPTION1, OPTION2, OPTION3;
        } 
    }
    
    class EnumTester {
        public void test () {
            ContainsInnerEnum ie = new ContainsInnerEnum ();
            // fail:
            // ie.temp = MYOPTIONS.OPTION1;
            // works:
            ie.temp = ContainsInnerEnum.MYOPTIONS.OPTION1;
        }       
    }
    

    The whole name of the MYOPTIONS contains the embedding class name.

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

Sidebar

Related Questions

This issue is very likely codeigniter specific. I have a controller called redirect.php that
So situation is following : We have some very old product, that has dozen
I have a very odd issue. When I execute a specific database stored procedure
The problem that I have is somehow very specific. I have to implement a
I have a particular application that needs to calculate something very specific, and while
I have a custom closed-hashset/open-addressing (i.e. no linked lists) class. It's very specific to
We have a very strange issue that we're dealing with. We have an MVC
I have a very specific set of needs and am looking for a library
I am very much a beginner to rails and I have a specific need
I have very little experience with ASP.NET and I am doing some self-training before

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.