Re: creating a new instance




"Tony Johansson" <johansson.andersson@xxxxxxxxx> skrev i en meddelelse
news:QCFke.138298$dP1.487265@xxxxxxxxxxxxxxxxxx
> Hello!!
>
> Here I create a new instance t of class Test and pass the referenc to
> method goo.
> When this method foo eventually finish will this instace t go out of scope
> and be garbage collected.?
> If not exactly what must occur so that the instance t be garbage
> collected.
>
> void foo()
> {
> Test t = new Test;
> goo(t);
> }
>
> //Tony
>
>

Short anwer: YES.......

But if you want to be sure, then set t = null; after the call to goo


Claus


.



Relevant Pages

  • Re: creating a new instance
    ... Here I create a new instance t of class Test and pass the referenc to method goo. ... When this method foo eventually finish will this instace t go out of scope and be garbage collected.? ...
    (comp.lang.java)
  • creating a new instance
    ... Here I create a new instance t of class Test and pass the referenc to method ... goo. ... When this method foo eventually finish will this instace t go out of scope ...
    (comp.lang.java)