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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:37:59+00:00 2026-05-23T07:37:59+00:00

Which Collection stores data in some specified order and can return or set elements

  • 0

Which Collection stores data in some specified order and can return or set elements according to index? I know that TreeSet implements SortedSet, hence stores data according to either natural ordering or some Comparator object provided by the programmer. But I don’t know how to retrieve or set elements in a TreeSet using index. On the other hand, ArrayList and some other structures can be used to retrieve or set their elements accoring to any index. But they don’t store elements in sorted order. Any way to have both features?

  • 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-23T07:38:00+00:00Added an answer on May 23, 2026 at 7:38 am

    You can just use an ArrayList and sort it using Collections.sort. If you have to insert elements, you can find the insertion-point using Collections.binarySearch, giving you O(log n) complexity for insertions (as opposed to O(n log n) for resorting). ArrayList provides an overload of add that takes a position parameter.

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

Sidebar

Related Questions

I have a sorted dictionary, which stores some data. Every two minutes or so
In my application, I have three collection objects which store data. The data which
I using a genric list(m_equipmentList ) which is collection of objects (Schedule_Payitem). How can
Hi I am trying to return a collection which may potentially have null date
I have an Asset object that has a property AssignedSoftware, which is a collection.
I need to store some data that looks a little like this: xyz 123
I have three classes a) Parent - Which contains some properties, an Item collection
I want to define some data in a row, which is master/detail in nature.
I have data database containing some rather large strings, each of which holds a
I have a set of information that I need to store in some kind

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.