time complexity or hidden cost of .length in java

后端 未结 5 1324
失恋的感觉
失恋的感觉 2020-12-06 11:03

I was looking at a project in java and found a for loop which was written like below:

for(int i=1; i

        
5条回答
  •  一生所求
    2020-12-06 11:24

    In an array, length is not a function as in List.size(). When you create an array in java, its length is a constant. So the cost is minimal

提交回复
热议问题