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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:06:00+00:00 2026-05-27T19:06:00+00:00

I am slightly new to Java and its pass-by-value concept and I am still

  • 0

I am slightly new to Java and its pass-by-value concept and I am still coming to terms with it. I have the following code and questions regarding this code.

Question: 1) Will my current code do a deep copy? or I will have to do a deep copy for Class A as well?

Question: 2) will a deep copy prevent changes to my para1 that I am passing around the classes?

Thanks in advance for your help.

Regards,
Atul.

public class A {
   private Double value;
}

public class I {
private Hashtable<Long, A> f2 = null;        

    I(I oldI){
        f2 = new Hastable<Long, A>(oldI);
    }
}

public class k {

private HashMap<Long, I > ob1 = null;


private HashMap<Long, I> ob2 = null; 

    k(Vector<I> para1){
    ob1 = new HashMap<Long, I >();
    for(int i=0; i < para1.size(); i++){
                    /* Question: 1  */
        ob1.put((long) i, new I(para1.get(i)));
    }
    }
}
  • 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-27T19:06:01+00:00Added an answer on May 27, 2026 at 7:06 pm

    1.) No your current code does not give you a deep copy. And if you want wo make a deep copy, you’d have to clone complex inner classes too.

    2.) Yes, a deep copy would prevent changes from object 1 if you make changes in object 2, even if object 2 is a clone of object 1.

    http://www.javaworld.com/javaworld/javatips/jw-javatip76.html

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

Sidebar

Related Questions

i am relatively experienced in Java coding but am new to C++. I have
Slightly related to my other question : What is the difference between the following:
Question slightly in the abstract... We have a situation where we have a struct
This is slightly off topic of programming but still has to do with my
I have a Java EE application that has REST web services attached to it.
Let's say I have a Java app which uses a (static) int constant from
Right now i am trying to learn more about java threading, and i have
I slightly remember from my age old Java days, that there was an RequestScope
I'm fairly new to java, and am used to enums essentially beeing nothing more
I have always been slightly confused with the amount of different IO implementations in

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.