Performance: Iterating through a List in Java

前端 未结 9 2150
半阙折子戏
半阙折子戏 2020-12-29 20:33

Is it slower to iterate through a list in Java like this:

for (int i=0;i

as opposed to:

9条回答
  •  温柔的废话
    2020-12-29 20:54

    There shouldn't be any noticeable differences in performance for normal lists.

    For linked lists, the iterator will be substantially faster, especially for large lists.

提交回复
热议问题