modern for loop for primitive array

前端 未结 5 1997
慢半拍i
慢半拍i 2021-02-05 16:39

Is there any performance difference between the for loops on a primitive array?

Assume:

double[] doubleArray = new double[300000];


for (double var: do         


        
5条回答
  •  独厮守ぢ
    2021-02-05 17:30

    Why not measure it yourself?

    This sounds a bit harsh, but this kind of questions are very easy to verify yourself.

    Just create the array and execute each loop 1000 or more times, and measure the amount of time. Repeat several times to eliminate glitches.

提交回复
热议问题