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.

Updated on: 2019-07-30T22:30:21+05:30

114 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements