Re: How to solve the error "The local variable may not have been instantiated"?
- From: Patricia Shanahan <pats@xxxxxxx>
- Date: Thu, 28 Sep 2006 15:09:52 GMT
Shawn wrote:
....
Thank you for your help. I didn't forget "= null;". My program still doesn't work. This is what I saw. If you insist, maybe it has to do with settings of compiler. I know regards to warnings, user can make selections so that somethings are considered as warnings, some not.
The initialization issue is an error, not a warning. The compiler should
never compile something with a possibly not initialized local variable,
because the results are undefined.
....
This won't work for me. I simplified my program in the posting. In my real program, after myClass object was created, the object was used several times. So it cannot be inside the if block:
return new MyClass(..); //myClass object created here
You should not get the "may not have been initialized" for a variable
that has an initial value in its declaration, as in:
MyClass myClass = null;
Make sure you only have one declaration with identifier myClass, so that
there is only one variable with that name.
If you are still having trouble, please post a short self-contained
example that reproduces it.
Patricia
.
- Follow-Ups:
- References:
- Prev by Date: Re: want to read all elements of xml using jdom ?
- Next by Date: Re: hashtable - select by wilecard... is it doable?
- Previous by thread: Re: How to solve the error "The local variable may not have been instantiated"?
- Next by thread: Re: How to solve the error "The local variable may not have been instantiated"?
- Index(es):
Relevant Pages
|
|