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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:16:44+00:00 2026-05-28T05:16:44+00:00

I want to declare an object in java that is like a a pointer

  • 0

I want to declare an object in java that is like a a pointer to a pointer in C++, let me show you an example :

//*** At the application startup

//Initialize a settings container class
Settings settings = //Load settings 

//Declaring static Application class that contain a reference to the settings container
Application.setSettings(settings);

//Get sub settings from settings container class
DatabaseSettings dbSettings =  settings.getDbSettings();
LogSettings logSettings = settings.getLogSettings();

//Initialize components 
DatabaseConnector dbConn = new DatabaseConnector(dbSettings);
Logger logger = new Logger(logSettings);

In the above code i have created a settings container class that contain all settings of my application components, then i have assigned each sub settings class to the related component, at this point during the execution of the program i want to update the settings and let the component of the application to see the updated settings, so for example during the execution i can update the settings container in this way :

//Update settings through Application static class 
Settings newSettings = //assign updated settings
Application.setSettings(newSettings);

Now the problem is that when i update the settings container at runtime the application static class will contain the updated reference to the newSettings instance while each sub Settings instance keep referencing the old sub settings, so :

dbConn      ---> settings.getDbSettings()
logSettings ---> settings.getLogSettings()

While i want that the two reference automatically reference to the new instance of the settings, so :

dbConn      ---> newSettings.getDbSettings()
logSettings ---> newSettings.getLogSettings()

It is like a pointer to pointer … Is it possible in Java ? How can it be done ?

  • 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-28T05:16:45+00:00Added an answer on May 28, 2026 at 5:16 am

    In Java, you only have references to objects. To have a reference to a reference you need some sort of indirection. e.g.

    AtomicReference<DatabaseSettings> refDatabaseSettings = new AtomicReference<DatabaseSettings>();
    
    refDatabaseSettings.set(dbSettings);
    
    DatabaseSettings dbSettings = refDatabaseSettings.get();
    

    You can pass the ref around and change it in one place. However, this won’t notify any of the references that it has changed, just allow all references to see the same thing when they check next time.

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

Sidebar

Related Questions

In my class I want to declare an event that other classes can subscribe
If I have a collection of static constants that I want to declare centrally
I am playing with Java and want to do a simple while loop that
I want to ask a question about Java. I have a user-defined object class,
Possible Duplicate: How to declare an array in Java? Suppose I have an object
I want to initialize a static collection within my C# class - something like
When I want to access the parent UIView of current UIView I declare object
Background Currently, if I want to create a new object in C# or Java,
In my code I want to declare an instance of my custom class like
let's say I want to instantiate a different type of object depending on certain

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.