1

Which is best way to initialize the ArrayList If I know the size of element in advance.

A)

List<Map<String, Object>> docList = new ArrayList<Map<String, Object>>(size);

OR

B)

List<Map<String, Object>> docList = new ArrayList<Map<String, Object>>();

What is the performance effect if I am using A or B.

mcacorner
  • 1,304
  • 3
  • 22
  • 45
  • http://stackoverflow.com/questions/15430247/why-start-an-arraylist-with-an-initial-capacity – Syam S Jul 01 '14 at 11:16
  • Possible duplicates are [1](http://stackoverflow.com/questions/15430247/why-start-an-arraylist-with-an-initial-capacity) and [2](http://stackoverflow.com/questions/4172480/whats-meant-by-parameter-int-initial-capacity-in-an-arraylist) – gemelen Jul 01 '14 at 11:16
  • duplicate; hence down voting it ! – Barun Jul 01 '14 at 11:17

0 Answers0