class TestMe{
public static void main (String args[]){
String s3;
System.out.print(s3);
}
}
why the compiler is giving a error,refernce object has a default value of null,why it is not the output...??
error: variable s3 might not have been initialized
It's an error because the JLS says so in §14.4.2. Execution of Local Variable Declarations:
If a declarator does not have an initialization expression, then every reference to the variable must be preceded by execution of an assignment to the variable, or a compile-time error occurs by the rules of §16.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With