This code:
int a;
if(a==1){ do something}
or
Image img;
if(img!=null){do something}
These codes generates the error:
Use of unassigned local variable 'variable-name'
I know what exactly this error says and how to resolve it. but what I wonder is that
- Shouldn't a variable that is declared and not assigned a value, have a value? like
null
for theImage
2.Why wouldn't it allow to even compare the variable? it can simply say that it doesn't match.