When I run the Java code again and again it prints different values of p
's address. Why is that?
Point code:
class Point {
}
Main Code:
public class HelloWorld
{
public static void main(String[] args) {
Point p = new Point();
System.out.println(p);
p = null;
System.gc();
}
}
Console Log:
test.Point@44585f2a
test.Point@5cfe174
test.Point@44585f2a
test.Point@44585f2a
test.Point@5cfe174
test.Point@44585f2a