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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:13:39+00:00 2026-05-20T08:13:39+00:00

I declared a POJO class with id, Name, age, contactNumber and Address attributes. I

  • 0

I declared a POJO class with id, Name, age, contactNumber and Address attributes. I declared all getters and setters. Now I am using HashMap<String, POJO_CLASS>. By default I sorts these values by Name attribute. Now my need is to search an object by id, and that method should return an object (which is stored in HashMap as value). So how can I use Collections.binarySearch() for this requirement.

  • 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-20T08:13:39+00:00Added an answer on May 20, 2026 at 8:13 am

    The better question is why would you want to. HashMap lookups are going to be very fast, O(1) time whereas binary searches are going to take O(lg(N)) time on Lists that have random access abilities (ArrayList).

    If you really want to use binary searches then you need to store your objects in a list (ArrayList probably) and have that list sorted and then call Collections.binarySearch(list, value).

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

Sidebar

Related Questions

My Hashmap as declared as HashMap<String, ArrayList<SortableContactList>> where SortableContactList list is a POJO class
I Declared my Array like this: Dim invoice_discountitems(100, 1) As String Now i set
I declared a dialog activity in my Manifest as follows: <activity android:name=.myDialog android:label=@string/title_dlg android:icon=@android:drawable/ic_dialog_alert
HI, My POJO class is @Entity @Table(name = seed) public class SeedUrl { @Id
I declared a WebView activity in the manifest like this: <activity android:name=.MyWebView android:label=@string/app_name android:configChanges=orientation|keyboardHidden
I declared a delegate: public delegate void Del(string message); Then i created a function
I have a map declared as follows: map < string , list < string
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
An enum structure declared in its own class is a member variable to the
Declared a map early on: map<char*,char*> rtable; // used to store routing information Now

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.