Why not always use ArrayLists in Java, instead of plain ol' arrays?

后端 未结 5 613
陌清茗
陌清茗 2020-12-03 18:17

Quick question here: why not ALWAYS use ArrayLists in Java? They apparently have equal access speed as arrays, in addition to extra useful functionality. I understand the

5条回答
  •  情书的邮戳
    2020-12-03 19:00

    Well don't always blindly use something that is not right for the job. Always start off using Lists, choose ArrayList as your implementation. This is a more OO approach. If you don't know that you specifically need an array, you'll find that not tying yourself to a particular implementation of List will be much better for you in the long run. Get it working first, optimize later.

提交回复
热议问题