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.