The java code is automatically optimized when compiling the code

for(int i=0;i<5;i++)
{
     int s = a[i];
     for(int j=0;j<5;j++)
}

for(int i=0;i<5;i++)
{
     for(int j=0;j<5;j++)
	{int s = a[i];}
}

From these two pieces of code, it can be seen that the first code is actually more optimized than the second code (at the level you wrote yourself)

But after the actual java code runs, because in Java, when the code is compiled, the compiler will perform a series of optimizations. In the end, the running performance of the two is theoretically the same.

Guess you like

Origin blog.csdn.net/qq_35798433/article/details/130501352