A single line If statement is giving compilation errors while trying to declare and assign a variable inside the single lined If block. Here's the code:
if(true)
String msg = "Hellow";
But once I declare the variable outside the If block, it doesn't complain any more. Here's the code:
String msg;
if(true)
msg = "Hellow";
Can someone please explain me why?
Aucun commentaire:
Enregistrer un commentaire