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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:24:43+00:00 2026-05-13T08:24:43+00:00

I am working with a Class that contains constants or parameter values that all

  • 0

I am working with a Class that contains constants or parameter values that all classes can reference for example;


public class Parameters {
   public static final String JUMP_TO_VALUE = "Parameters.JUMP_TO_VALUE";
   public static final String EXCEPTION_ID  = "Parameters.EXCEPTION_ID";
}

Some of the foundation classes in my application will use the parameter values in the Parameters class like so:


   mapOfValues.put( Parameters.JUMP_TO_VALUE, "some_value")

This is simple enough I have some basic values in Parameters that most of my base classes will use them. There will be many situations where I will need to add addition parameters to the Parameters class, but I don’t want to over populate or pollute the Parameters class ever time a new parameter is identified. I would rather create some subclass of Parameters like:


  public class NetworkParameters extends Parameters {
      public static final String HOST_NAME = "NetworkParameters.HOST_NAME";
      public static final String POST_NUM  = "NetworkParameters.PORT_NUM";
 }

Some of my specific classes will use the values that are contained in this class versus putting them in the Parameters class.

These specific classes that need HOST_NAME for example I don’t want them to reference the NetworkParameters class but rather the Parameters class.

I am sure people have done this before but I am looking for advice on how best to implement this design.

  • 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-13T08:24:44+00:00Added an answer on May 13, 2026 at 8:24 am

    It is simply not possible, in the exact way you describe it.

    When you reference static objects, you refer to the class that those objects are declared in. Quite simply, if you declare a constant in the NetworkParameters class, it does not exist in the Parameters class and is not accessible as such.

    Separating vast numbers of parameters into different containing classes (which don’t need to be subtypes of each other as this achieves nothing) is quite good practice and often used. Why do you have such an aversion to just using NetworkParameters.POST_NUM, as this is the name of the parameter and sounds completely sensible to me?

    One thing that may help you (depending on your own tastes) is to use Java 5’s static import feature. If, at the top of a class file, you declare

    import static the.package.name.Parameters.*;
    import static other.package.NetworkParameters.*;
    

    then you will be able to use all of the constant names from both classes without any prefix at all. This is often quite nice when it’s obvious what comes from where – but it can become a nightmare if you’re statically importing from a few classes, especially if you don’t have an IDE to work out the reference for you.

    But again – why do you want to reference them as Parameters.FOO, but want them to live in a separate class? Either approach (everything in one file, different constants in different files) is good and fine if you do it completely, but you can’t magically change the laws of Java references because you don’t like the look of them. 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 295k
  • Answers 295k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The proprietary variations of user-select will work in most modern… May 13, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer try: using (imgMonthGraph.Image) { imgMonthGraph.Image = UIImage.FromFile("A.png"); } works for… May 13, 2026 at 6:54 pm
  • Editorial Team
    Editorial Team added an answer It sounds like that'd take a lot of work creating… May 13, 2026 at 6:54 pm

Related Questions

I have created a custom UIView that I would like to use on multiple
I am using the AJAX autocomplete add-on to the <asp:textbox> control. I have everything
i am receiving a piece of plain html from an ajax request. <h1>Title</h1> <div>
Greetings! I am working on an AS2 website with MovieClips for pages that swap
I am working on implementing a function that would execute another function a few

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.