Why does the following work fine?
String str; while (condition) { str = calculateStr(); ..... }
But this one is said to be dangerou
Declaring inside the loop limits the scope of the respective variable. It all depends on the requirement of the project on the scope of the variable.