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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:37:42+00:00 2026-05-26T20:37:42+00:00

I am retrieving a List from a JPA query, ordered by effectiveDate. There could

  • 0

I am retrieving a List from a JPA query, ordered by effectiveDate. There could be duplicate entries except for the date column, and I’ll be ordering them most recent date first (desc). All I want in the set are all the entries with the newest effectiveDate; dupes with older effectiveDates are not allowed in the Set.

If I create a HashSet by passing this List into the constructor, does the new Set only contain the first entries in the List, only the ones with the “newest” effectiveDates?

In other words, are Sets initialized in List order when they are created from a List?

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-05-26T20:37:43+00:00Added an answer on May 26, 2026 at 8:37 pm

    If you create a HashSet from a collection with duplicates, only the first of each duplicate will be added to the hashset.

    It adds the items in the list in order, and the add method does not overwrite duplicates.

    Although this behavior is not specified, it’s highly unlikely to change.

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

Sidebar

Related Questions

Using the following code, I'm retrieving a list of Integers from a DB and
When retrieving values from a DataRow is it better to use the column name
I am retrieving a list of objects from json url and displaying it like
Having a problem retrieving a list of items from the database. This is what
I am retrieving a list of values from a sharepoint list, which works well
I am having issues with retrieving list items from a different site collection. I
I am retrieving a list of items from a URL and displaying them in
Currently I am retrieving list items from a sharepoint list via the provided web
I have a problem retrieving items from a fairly large list. I can quickly
I am retrieving a list of files from a web service and displaying them

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.