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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:20:22+00:00 2026-05-11T09:20:22+00:00

If I have a member variable such as this (declared in the body of

  • 0

If I have a member variable such as this (declared in the body of a class)

private Dot[] dots=new Dot[numDots]; 

I loop through all members of this array, and:

1) Pass every Dot object to a function of another class, which:

2) Passes it to yet another function of a 3rd class, if some conditions are met

3) And the 3rd class changes some properties of the Dot object

then when this object is returned to the original/parent class, would those changes to its properties have retained? Or would it be treated like a local variable by the 2nd/3rd functions?

  • 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. 2026-05-11T09:20:22+00:00Added an answer on May 11, 2026 at 9:20 am

    Yes, the changes to the properties are retained. Java is 100% pass-by-value, however, when you pass an object, the ‘value’ passed is truly a pointer to the object. Thus, when you change an object in a method, you’re changing the actual object passed in.

    That is, if you have the following method, then the calling method will see the changes:

    private void updateMyDot(final Dot aDot) {   aDot.dotColor = new Color(255,255,255); } 

    but if you do the following, then the calling method will not see the changes.

    private void updateMyDot(/* not final */ Dot aDot) {   aDot = new Dot();   aDot.dotColor = new Color(255,255,255); } 

    In the second example, the caller will not see any changes and will not see the newly created Dot object.

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

Sidebar

Related Questions

I have a member function of a template class declared as such: template <class
I have a class AudioManager with a member of type AudioBufferList * . (This
If I have a class defined as such: class classWithInt { public: classWithInt(); ...
let's say i want to have a member variable for a pointer to std::vector
why or for what reason is it not possible to declare a class member
One of my WCF functions returns an object that has a member variable of
I have a class that has two method in it, one calls a class
Section 7.1 of the C++ Standard mentions about 'extern' as a storage class specifier.
Okay, it's been such a long day that I am just going to look
I am trying to make a wrapper in Objective-C so I don't have to

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.