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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:34:03+00:00 2026-06-13T00:34:03+00:00

trying to initialize my array at 1 and have it double every time it’s

  • 0

trying to initialize my array at 1 and have it double every time it’s input fills up. this is what i have right now

int max = 1;
 PhoneRecord[] records = new PhoneRecord[max];
      int numRecords = 0;
      int size = Integer.parseInt(length.records[numRecords]);
 if (size >= max) {
   size = 2*size;
 }

but it’s clearly full of fail. any suggestions or guidance would be great, thanks.

  • 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-06-13T00:34:06+00:00Added an answer on June 13, 2026 at 12:34 am

    OK, you should use an ArrayList, but several other folks already told you that.

    If you still want to use an array, here’s how you’d resize it:

    int max = 1;
    PhoneRecord[] records = new PhoneRecord[max];
    int numRecords = 0;
    
    void addRecord(PhoneRecord rec) {
        records[numRecords++] = rec;
        if(numRecords == max) {
            /* out of space, double the array size */
            max *= 2;
            records = Arrays.copyOf(records, max);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I declare an int array, then initialize it with chars? I'm trying to
I am trying to initialize a multidimensional array. Here is my syntax; this does
How do I initialize a 2D array in Perl? I am trying the following
I'm trying to initialize string with iterators and something like this works: ifstream fin(tmp.txt);
I am trying to initialize an array automatically when i create an instance of
I'm trying to squeeze every bit of performance in my Delphi application and now
I have been trying to use 2D array as a parameter to a constructor
I am trying to initialize a node array in the node class, they are
I'm trying to initialize an array with self-invoking function, assume for simplicity as an
I am trying to understand why my code crashes. I have an array of

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.