I'm a c++ programmer, and I'm currently learning Java, and when trying to understand how Java works I wondered... if I save an object from a data structure such ArrayList in a variable, and then erase that object, will that object still be there? Since assigning an object to a variable stores the pointer to that object, once it's erased, will it be a null object or will that be a copy of the erased object?
For example
ArrayList list = new ArrayList<Object>();
Object object = list.getObject(...)
list.remove(...)
Will object be null?
Would this change the behaviour?
ArrayList list = new ArrayList<Object>();
Object object = new Object();
object = list.getObject(...)
list.remove(...)