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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:17:24+00:00 2026-06-14T16:17:24+00:00

Let me start by saying that I can’t put any code here because Internet

  • 0

Let me start by saying that I can’t put any code here because Internet on my laptop is not working so I am posting this through my phone. Okay the problem is that say I have two classes: class one and two. Class one has an ArrayList as one of its attributes and it calls a void method from class two and passes that ArrayList as a parameter. Now that method initializes another ArrayList and makes it equal to the parameter passed by me and makes changes to that new ArrayList. Funny thing is that even my original ArrayList which was passed as parameter is also changing. What could be the possible reason?

  • 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-14T16:17:27+00:00Added an answer on June 14, 2026 at 4:17 pm

    The problem is that when you use = to make the new ArrayList a copy of the original, you’re just creating a new reference to the same ArrayList. Think of it as two variables pointing at the same object.

    Check this out, it might help you understand what’s happening: Is Java "pass-by-reference" or "pass-by-value"?

    In order to solve your problem, you need to create a new ArrayList by using the “new” keyword and then adding all of the objects, or use the clone() method.

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

Sidebar

Related Questions

Let me start by saying that I am not an expert in any one
Let me start by saying that this app was working fine the day before.
First off, let me start by saying that I am totally new to working
Let me start out by saying that I'm not a C developer and I
Let me start of by saying that I am inexperienced with JavaScript. Here is
Let me start by saying that this question can possibly be answered by AI
Let me start off by saying that I am not an expert in C.
Let me start off by saying that the code in question is part of
Let me start out by saying that I'm not a JavaScript developer so this
Let me start by saying that I'm not a power-JavaScript/jQuery programmer, I do very

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.