public class LocalVariables {
static public void main(String args[]){
int var;
if(args.length > 0){
var = 10;
}
else{
var = 20;
}
System.out.println(var);
}
}
Here if I remove else
part it's showing compilation error as:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The local variable var may not have been initialized
Explain how the local variable value is initialized if I use else
part.