Hashmap returning reference instead of copy <p>I have one model called Person with properties </p> <pre><code>name image age amount </code></pre> <p>and I have a singleton hashmap <code>Hashmap&lt;String,Person&gt; globalPersonList</code> which contains list of person objects.</p> <p>I am trying to retrieve one single object from my hashmap like</p> <pre><code>Person existingPerson = globalPersonList.get("key"); </code></pre> <p>I want to create a new <code>Person</code> instance and initiallize with <code>existingPerson</code> properties like</p> <pre><code>Person person = new Person(); person = globalPersonList.get("key"); </code></pre> <p>Now I want to set amount field to this person object. I tried like </p> <pre><code>newPerson.setAmount(100); </code></pre> <p>but it shouldn't affect <code>globalPersonList</code>. I want amount value only in my newPerson object. But right now this is set in <code>globalPersonList</code> also. after setting amount if I try to </p> <pre><code>globalPersonList.get("key").getAmount() </code></pre> <p>it is giving the amount that I set. Is it using the reference to new object? I want a seperate copy of Person object so that it won't affect main hashmap.</p>