Consider we have a class Node in java like this:
class Node{
Node prev;
Node next;
}
when we create a new Node (Node sample = new Node();
) how does the JVM allocate enough memory for the object. Its size might change in the future. For example, later I can set sample.setPrev(new Node())
and so on. so if JVM considers indexes from 1000 to 2000 in memory for this sample object then it's size might change and the memory index 2001 might not be empty for our use.