I have two classes which second inherit by first.
then I have this:
First[] tab = new First[5];
tab[0] = new First();
tab[1] = new First();
tab[2] = new First();
and my question is: If I make this:
tab[1] = new Second();
what’s happened whitch memory which I use to invoke tab[1] in first time? It’s go to Garbage Collection and memory is free?
If not what can I do to free it?
Any help would be appreciated.
Replacing an object from an array causes that object to no longer be referenced by the array.
Like any other object, it will eventually be garbage collected if no other rooted objects are referencing it.