diff --git a/src/main/java/jvm/gc/PrintMemoryAddress.java b/src/main/java/jvm/gc/PrintMemoryAddress.java new file mode 100644 index 0000000..840215b --- /dev/null +++ b/src/main/java/jvm/gc/PrintMemoryAddress.java @@ -0,0 +1,21 @@ +package jvm.gc; + +public class PrintMemoryAddress { + public Object getObj() { + Object o = new Object(); + System.out.println(STR."The addree is \{System.identityHashCode(o)}"); + return o; + } + + public void showObj() { + Object o = getObj(); + Object o2 = new Object(); + System.out.println(STR."Now the addree is \{System.identityHashCode(o)}"); + System.out.println(STR."The addree of o2 is \{System.identityHashCode(o2)}"); + } + + public static void main(String[] args) { + PrintMemoryAddress printMemoryAddress = new PrintMemoryAddress(); + printMemoryAddress.showObj(); + } +}