Skip to content

Instantly share code, notes, and snippets.

@kirkbackus
Created July 8, 2015 14:52
Show Gist options
  • Select an option

  • Save kirkbackus/e96ad7df18a80190e994 to your computer and use it in GitHub Desktop.

Select an option

Save kirkbackus/e96ad7df18a80190e994 to your computer and use it in GitHub Desktop.

Revisions

  1. kirkbackus created this gist Jul 8, 2015.
    17 changes: 17 additions & 0 deletions TestShallowCopy.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import java.util.Map;
    import java.util.HashMap;

    public class TestShallowCopy {
    public static void main(String[] args) {
    Map<String, Integer> a = new HashMap<String, Integer>();
    a.put("TEST", 1);

    Map<String, Integer> b = new HashMap<String, Integer>(a);

    a.clear();

    System.out.println("TEST: "+b.get("TEST"));
    System.out.println("A-size: "+a.size());
    System.out.println("B-size: "+b.size());
    }
    }