I often use Lists in my Android applications. Right now I am creating a Twitter page which lists a maximum of 50 "tweets" of a user.
I have a List defined like this:
List<Tweet> tweets = new ArrayList<Tweet>(MAX_TWEETS);
Where Tweet
is a custom object type holding twitter update information(text, date, username, etc) and MAX_TWEETS
is a constant integer value(50).
Questions:
What is the benefit of setting the initial capacity of this List
, if any?
Should I bother setting a capacity when i know my list will be this small? When should i/should i not be setting a capacity?