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

The Archive Base Latest Questions

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

I’m coding in Java, but most languages would do just fine. Right now, I

  • 0

I’m coding in Java, but most languages would do just fine.

Right now, I have an implementation like this:

I have an array that stores objects from a class. The array’s length is 10,000.

This is for a little project I working on. Essentially, over time, any place in the array can be unused or have an object in it. Objects can be created or destroyed at any moment.

What I was trying to figure out was the best way to store and recall them to minimize time for two steps:

  1. Creating an object. Cycling through the array until you find an open slot can be slow when lots of instances are near the front.

  2. Drawing an object. I have to cycle through the array constantly, and, based on the existence of an instance, retrieve and display information regarding it.

My current system uses a list of the Objects, as well as a list of Booleans. When creating an object, I just cycle through till the first empty place in the array, then fill it, and to draw, I just go over the whole thing.

Granted, it isn’t slow enough to make the project impossible, but I’d still like to know the most efficient method.

  • 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-19T22:15:27+00:00Added an answer on May 19, 2026 at 10:15 pm

    The best way is not to do this. Use one of the Java collections. If you aren’t going to be adding or removing things very often, maybe use a ArrayList. If you are, then use a LinkedList. And if you want to maintain a mapping to particular indices, you might consider e.g. a TreeMap. These are all iterable.

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

Sidebar

Related Questions

No related questions found

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.