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 7079957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:44:08+00:00 2026-05-28T06:44:08+00:00

How much space does a java string array take up? More specifically, how much

  • 0

How much space does a java string array take up?
More specifically, how much space (in bytes) does a string array that looks something like this:

Longbowman 
kingdom   
lord    
weapon1,weapon2,weapon3    
armor1,armor2,armor3

I ask this because I’m going to create a program that has 5,000+ of these arrays and want to know how much space it’ll take up so I’ll know if I should rework the data storage.

So to recap, how much space does a string array (if its quantifiable) take up?

  • 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-28T06:44:08+00:00Added an answer on May 28, 2026 at 6:44 am

    The string array is just an array of references – an array of size N will take approximately (N * 4 + 20) or (N * 8 + 20) bytes depending on the size of a reference in your JVM.

    If you’re interested in your total storage, you should work out how many separate String objects you’ve got, and also how many arrays you’ve got. If you’ve got 5000 arrays but they mostly contain references to the same few strings, it’s likely to be fine. If you’ve got 5000 arrays each of which contains 5 strings which aren’t used anywhere else, that’s 25,000 strings… which still probably isn’t very much (a string of length 20 will probably take about 60 bytes).

    Of course, context matters here: what’s your code going to run on? If it’s running on a desktop PC, than taking a few megs probably isn’t a problem… it might be more of an issue on a phone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How much space does string.Empty take in CLR? I'm guessing it's just one byte
I would like to have an iframe take as much vertical space as it
I'd like to show a Dialog that occupies as much screen space as possible.
How much space does an object takes from the memory heap? How can this
I have; var maxVal = l.TakeWhile(x=>x < val).Where(x=>Matches(x)).Max(); How much space does this need
In C how much space does a bool (boolean) take up? Is it 1
How to find how much disk space is left using Java?
I would like to know how much disk space a directory is going to
Around how much space does a Sharepoint Collaboration Portal use up by default (when
How much layout space does a web-browser allocate when initially rendering: <img src=image.jpg />

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.