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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:09:56+00:00 2026-06-13T22:09:56+00:00

I have small issue in arraylist android, let me tell you where i’m facing

  • 0

I have small issue in arraylist android, let me tell you where i’m facing the issue.

I have a custom contact object, which holds the details about name, contact number and a unique ID. when i query the database i get the list and i will be storing in an ArrayList.

Here how i do

Arraylist<contact> ctlist = new Arraylist(contact);
ctlist = getitemfromDB();

in the next scenario, i do query and get some set of contact object based on certain condition. i get
again contact list objects.

Arraylist<contact> newctlist = new Arraylist(contact);
newctlist = getitemfromDB(condition);

Now, if i pick any object from newctlist and search in ctlist, though the object is present in ctlist
compiler says object not found.

may i know what is wrong with the above way, if i search inside same list i.e if i pick an object from newctlist and search in it, i will get correct expected result.

what would be the problem.

  • 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-06-13T22:09:58+00:00Added an answer on June 13, 2026 at 10:09 pm

    As told by Mitch Wheat, you are trying to compare two different objects. That’s because List uses equals method to retrieve specific object. I think you didn’t override it in your custom class.
    Just implement equals and hashCode methods based on fields in your contact class.

    In fact, you should try to always override equals and hashCode methods in classes where equality have a different meaning than just reference equality, e.g. beans. Please have a look there and there. Moreover, if you can, read chapter three from Josh Bloch’s “Effective Java” which contains quality rules for those implementations (By the way, read the whole book, it’s great).

    Please note that there are librairies helping you implementing correctly those (Java7 java.util.Objects, Guava Objects, apache commons EqualsBuilder and HashCodeBuilder)

    Be careful as those methods must have very precise mathematical property

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

Sidebar

Related Questions

i have a small issue which my text field insist to inhert the CSS
I have a small issue actually getting variable to show - let alone how
I have a small issue with a CA2000 warning. In my project which is
I have a small issue which I'm hoping someone can help me resolve. Copied
I have a small issue accessing a byte[] : I have a binary object
I have a small issue with which I'm struggling. I need to align a
I have a small issue with sessions. I have built a small shopping cart-esque
I have a small issue with a method that should save the text contained
I have a small issue(for lack of a better word) with MySQL db. I
I am just new to programming in Unix and have a small issue that

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.