Difference between declaring a variable before or in a Java loop.



Performance wise, there is hardly any difference. But it is good to keep a variable local to the scope it is used. So declaring a variable inside Java loop is generally preferred.


Advertisements