Java Performance - ArrayLists versus Arrays for lots of fast reads

前端 未结 12 1548
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 20:20

I have a program where I need to make 100,000 to 1,000,000 random-access reads to a List-like object in as little time as possible (as in milliseconds) for a cellular automa

12条回答
  •  鱼传尺愫
    2020-12-14 20:44

    An Array will be faster simply because at a minimum it skips a function call (i.e. get(i)).

    If you have a static size, then Arrays are your friend.

提交回复
热议问题