Consider:
public SomeClass implements SomeInterface{...}
SomeClass obj = new SomeClass();
SomeInterface x = obj;
I am trying to relate line 3 to my very basic understanding of memory management.
I know the memory location represented by “obj” just contains a pointer to the memory location of SomeClass. Assuming I am using a 64bit JVM, then up to 64 bits are allocated for the “obj” pointer. What is created in memory when the JRE implements x? Is it just a 64bit pointer to SomeClass?
Every object reference takes up the same amount of memory, no matter how you declare it.
So
xandobjare two distict references, which just happen to point at the same thing.