dcsimg
Are all uses of "this" legal in a constructor?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, June 13, 2001 03:10 AM

Can I for instance do something like this:

			
public MyClass(HashSet someSet) {
...
someSet.add(this);
}


The compiler accepts it, but is it safe in runtime?

Re: Are all uses of "this" legal in a constructor?

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, June 13, 2001 06:06 AM

When the constructor block get executed the object is already created so it's safe.

Re: Are all uses of "this" legal in a constructor?

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, June 13, 2001 06:06 AM

When the constructor block get executed the object is already created so it's safe.
About | Sitemap | Contact