S
Shawn
Hi,
I am writing a program and I run into a lot of annoying errors: local
variable may not have been initialized. For example:
public class MyClass
{
public void aMethod()
{
double number; //declare a local variable
...//code
if (number > 0) //Error: the local variable may not have been
initialized
{
...//code
}
...//code
return;
}
}
How to avoid such errors? Maybe initialized to 0:
double number = 0.0;
will get rid of the error. But my program has about 30 local variables.
I am using:
double num1, numABC, iX, ..., w;
I hate to do the following:
double num1 = 0.0;
double numABC = 0.0;
double iX = 0.0;
I think such message should be a warning, instead of error. Of course,
the variable has at least a default value.
I am writing a program and I run into a lot of annoying errors: local
variable may not have been initialized. For example:
public class MyClass
{
public void aMethod()
{
double number; //declare a local variable
...//code
if (number > 0) //Error: the local variable may not have been
initialized
{
...//code
}
...//code
return;
}
}
How to avoid such errors? Maybe initialized to 0:
double number = 0.0;
will get rid of the error. But my program has about 30 local variables.
I am using:
double num1, numABC, iX, ..., w;
I hate to do the following:
double num1 = 0.0;
double numABC = 0.0;
double iX = 0.0;
I think such message should be a warning, instead of error. Of course,
the variable has at least a default value.