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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:06:19+00:00 2026-05-15T16:06:19+00:00

My problem is to store details of people in Java. I looked up at

  • 0

My problem is to store details of people in Java. I looked up at the Oracle website topic How to Use Tables and found out that one can use object arrays(2 dimensional) to store details.

But my interest is to make a dynamic object array so I can store any amount of data and also take input to store those details from the user. For instance, at the beginning of the program I can specify an object array to hold 5 records, but I actually want an array that could add another available location if I need to add more records (dynamic).

Is there a way this is possible in java ? If so, do you happen to know any good places I could start, perhaps a link. Is storing using an Object array the best option?

  • 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-15T16:06:19+00:00Added an answer on May 15, 2026 at 4:06 pm

    An array holds homogenous data, i.e. usually the class of everything in every cell of an array is the same. You will likely not want to store a person’s name and his shoe size in fields of the same type, so… let’s drop one of the array’s dimensions. You should declare a class called something like Person and specify within it all the attributes you want to store for a person. Having done that, you will only be wanting to store a one dimensional array (or something) of Person.

    Next, note that arrays are fixed in size. If you want to extend an array, you would need to allocate a new, bigger array, copy the contents of the old one into the new one and then go on working with the new one in place of the old one.

    That’s a lot of work, and error prone. In the modified words of Apple, there’s a class for that! The older qualified class was Vector, a class where you could store objects and that would grow every time you add a new object to it. Nowadays, the class to use for this (it’s a bit more efficient) is ArrayList. Same thing: You do

    ArrayList<Person> myList = new ArrayList<Person>();
    

    and then you can repeatedly

    newPerson = new Person("Bruce", "Wayne", 1972, "Gotham City");
    myList.add(newPerson);
    

    and you can access folks in the list by doing

    int personNumber = 0;
    Person retrievedPerson = myList.get(personNumber);
    

    or even

    for (Person someone : myList) {
       System.out.println(someone);
    }
    

    EDIT

    OK, to store people with an ID and access them by that ID assuming the person ID is an integer, some appropriate code would be:

    TreeMap<Integer, Person> myMap = new TreeMap<Integer, Person>();
    
    newPerson = ...
    myMap.put(newPerson.getId(), newPerson);
    

    then you can retrieve it with

    Person p = myMap.get(id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store data, the problem is that I only know the name
I use Zend_Auth to authenticate users and then store their details in the default
I have a problem with my application (first one) when people downloading it from
I've got an ExtJS interface that addresses a problem I'm sure tons of people
Am developing one using nodejs scraping and mysql. I want to store details into
I have a problem to Store file (from a remote API) in MongoDB, i'm
Problem when I enter any input which has underscore (_) data will store to
I am working on a store locator web app and I have a problem
Here is my problem. I am trying to store data from my web app
How to store Effect parameters in class ? I'm stuck in this problem for

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.