First program:
class Demo {
public static void main(String args[]) {
Object obj ;
while(true) {
obj = new Object();
}
}
}
2nd program:
class Demo {
public static void main(String args[]) {
Object obj = null;
while(true) {
obj = new Object();
}
}
}
question : is there any difference in terms of scope of obj
in the two programs where obj is assigned value in the loop(in first program) and obj is assigned null value initially (in second program).