I want to ask which piece of code is more efficient in Java? Code 1:
void f()
{
for(int i = 0 ; i < 99999;i++)
{
for(int j = 0 ; j < 99999;j++)
{
Stop micro-optimizing. These little tricks don't make programs run much faster.
Concentrate on big picture optimizations and writing readable code.
Declare variables where they make sense, and where it helps understanding the semantics of the overall code in the bigger context, not because you think it's faster one place over another.