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

  • Home
  • SEARCH
  • 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 6830319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:36:13+00:00 2026-05-26T22:36:13+00:00

In reference to the link: File IO Tuning , last section titled Further Tuning

  • 0

In reference to the link: File IO Tuning, last section titled “Further Tuning” where the author suggests using char[] to avoid generating String objects for n lines in the file, I need to understand how does

char[] arr = new char{'a','u','t','h', 'o', 'r'}

differ with

String s = "author"

in terms of memory consumption or any other performance factor? Isn’t String object internally stored as a character array? I feel silly since I never thought of this before. 🙂

  • 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-26T22:36:14+00:00Added an answer on May 26, 2026 at 10:36 pm

    In Oracle’s JDK a String has four instance-level fields:

    • A character array
    • An integral offset
    • An integral character count
    • An integral hash value

    That means that each String introduces an extra object reference (the String itself), and three integers in addition to the character array itself. (The offset and character count are there to allow sharing of the character array among String instances produced through the String#substring() methods, a design choice that some other Java library implementers have eschewed.) Beyond the extra storage cost, there’s also one more level of access indirection, not to mention the bounds checking with which the String guards its character array.

    If you can get away with allocating and consuming just the basic character array, there’s space to be saved there. It’s certainly not idiomatic to do so in Java though; judicious comments would be warranted to justify the choice, preferably with mention of evidence from having profiled the difference.

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

Sidebar

Related Questions

When debugging a link error ( undefined reference to _dso_handle ) using the Android
I want to link to a section in an external file, but I can't
I have css file reference in my website which is shown as below: <link
i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following:
Does anyone know of a link to a reference on the web that contains
With reference to Problem with date day/month reversing on save I have further noted
I need a way to link or reference XML nodes among each other. So
I can create .o file with g++ -c test.cpp -std=c++0x , but cant link
How do you link 2 c library files, to a c++ file? Right now

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.