Redeclare an array;what happens to its objects?

B

Behzad

hi,

i want to know what happens to objects in an array if i redeclare the
array..
look at the following code:

////my code

public MyClass[] myarray=new MyClass[ somevalue ];

for( int counter = 0 ; counter < somevalue ; counter++ )
myarray[counter]=new MyClass();

///somewhere elese
myarray=new MyClass[ some_new_value ]
////end of code


in this case what will happen to my old intances of MyClass?did they
destroy when i redeclare myarray with some_new_value?

thanks in advance.
behzad
 
J

Joanna Carter [TeamB]

"Behzad" <[email protected]> a écrit dans le message de (e-mail address removed)...

| i want to know what happens to objects in an array if i redeclare the
| array..

If there are no other references to the contained objects, then they will be
GCed.

Joanna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top