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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:16:35+00:00 2026-06-09T10:16:35+00:00

I am currently creating an Android app and thought that I had a problem

  • 0

I am currently creating an Android app and thought that I had a problem with saving data internally, etc. It turned out that the problem had nothing to do with that, but with my understanding of Java.

The problem is that when I do

myObject1 = myObject2;

and use myObject1 in myObject3 which might be a list, or whatever (in my case a Hashtable) and then change myObject2, myObject3 gets changed accordingly, as well. What is this called, and where can I learn more about it? How do I assign myObject2 to myObject1 so that myObject1 is completely “independent”?

  • 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-09T10:16:37+00:00Added an answer on June 9, 2026 at 10:16 am

    Variables that are Objects in Java are called references and refer to the same location in memory. If you want two objects of the same type that don’t refer to the same location in memory in need to allocate memory for them on your machine by using the new keyword.

    Below both variables myObject1 and myObject2 are references to an OBJECT1 object, but that don’t exist at the same memory location:

    OBJECT1 myObject1 = new OBJECT1();
    OBJECT1 myObject2 = new OBJECT1();
    

    If assigning an object to another is important you can look into the clone() method or use a copy constructor:

    public OBJECT1(OBJECT1 toCopy)
    {
        this.field1 = toCopy.field1; 
        this.field2 = toCopy.field2; 
        this.field3 = toCopy.field3; 
        this.field4 = toCopy.field4;     
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so here is the problem. I am currently creating an Android app that is
I'm currently in the process of creating an android app that displays a biological
I am currently creating an Android app that requires using the Android phone's name
I'm currently creating my first android app and I've a simple class 'Player' I
im currently creating a graph for an app, using coreplot and have a problem
I'm currently creating an iPhone app (Xcode 4.3.1, IOS 5) that could use Bluetooth
I'm creating an android app where user loads some data from an online server
I am creating an android app that basically records an applies an Effect on
I am a php/mysql developer learning android. I am creating an android app that
So I've got an activity in my app that is currently marked as android:launchMode=singleTop

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.