Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:23:11+00:00 2026-05-22T16:23:11+00:00

I often use Lists in my Android applications. Right now I am creating a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:23:11+00:00Added an answer on May 22, 2026 at 4:23 pm

    Default capacity of ArrayList is set to 10 (see jdk 1.6 source). That means array of size 10 will be allocated on creation. If you will be adding element number 11 the capacity will increase to 16. Then increase again once you reach 21.

    If you don’t expect more than 50 elements the array will resize at most 3 times. Given that small number, it really does not matter much. Set it to 50 if it gives you a piece of mind of saving on array copy.

    Actually this is correct formula of size increase:

    int newCapacity = (oldCapacity * 3)/2 + 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have resharper installed and I use the todo list functionality pretty often. My
I am working on a game for android right now. It is a game
I have 11 lists of different length, imported into R as p1,p2,p3,...,p11. Now I
By default the webjump hotlist has the following which I use quite often: M-x
At my place of employment we have a temperamental proxy server which often makes
I often use stored procedure for data access purpose but don't know which one
In my program I often use collections to store lists of objects. Currently I
I often use webservice this way public void CallWebservice() { mywebservice web = new
I often use the top command to see what is taking up resources. Mostly
I often use the execv() function in C++, but if some of the arguments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.