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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:47:26+00:00 2026-05-10T19:47:26+00:00

In Java, we can always use an array to store object reference. Then we

  • 0

In Java, we can always use an array to store object reference. Then we have an ArrayList or HashTable which is automatically expandable to store objects. But does anyone know a native way to have an auto-expandable array of object references?

Edit: What I mean is I want to know if the Java API has some class with the ability to store references to objects (but not storing the actual object like XXXList or HashTable do) AND the ability of auto-expansion.

  • 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. 2026-05-10T19:47:26+00:00Added an answer on May 10, 2026 at 7:47 pm

    Java arrays are, by their definition, fixed size. If you need auto-growth, you use XXXList classes.

    EDIT – question has been clarified a bit

    When I was first starting to learn Java (coming from a C and C++ background), this was probably one of the first things that tripped me up. Hopefully I can shed some light.

    Unlike C++, Object arrays in Java do not store objects. They store object references.

    In C++, if you declared something similar to:

    String myStrings[10]; 

    You would get 10 String objects. At this point, it would be perfectly legal to do something like println(myStrings[5].length); – you’d get ‘0’ – the default constructor for String creates an empty string with length 0.

    In Java, when you construct a new array, you get an empty container that can hold 10 String references. So the call:

    String[] myStrings = new String[10]; println(myStringsp[5].length); 

    would throw a null pointer exception, because you haven’t actually placed a String reference into the array yet.

    If you are coming from a C++ background, think of new String[10] as being equivalent to new (String *)[10] from C++.

    So, with that in mind, it should be fairly clear why ArrayList is the solution for an auto expanding array of objects (and in fact, ArrayList is implemented using simple arrays, with a growth algorithm built in that allocates new expanded arrays as needed and copies the content from the old to the new).

    In practice, there are actually relatively few situations where we use arrays. If you are writing a container (something akin to ArrayList, or a BTree), then they are useful, or if you are doing a lot of low level byte manipulation – but at the level that most development occurs, using one of the Collections classes is by far the preferred technique.

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

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 60k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Try a UNIXSocket You use a local path to specify… May 11, 2026 at 9:30 am
  • added an answer You'll want to do it before the browser (or bot)… May 11, 2026 at 9:30 am
  • added an answer I am a great fan of Qt but I have… May 11, 2026 at 9:30 am

Related Questions

In Java, we can always use an array to store object reference. Then we
What is the use of anonymous classes in Java? Can we say that usage
Can we use Java in Silverlight?
In Java, we're using the following package to programmatically create excel documents: org.apache.poi.hssf If
At work we do almost everything in Java and perl, but I wanted to
Me and some friends are writing a MORPG in Java, and we would like
We are working with large amounts of data, all tagged in UTC (in Java).
This question has been discussed in two blog posts ( http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/ , http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/ ),
I recently got involved in a Java project at work: we're using MyEclipse for
We noticed that lots of bugs in our software developed in C# (or Java)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.