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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:26:51+00:00 2026-06-16T02:26:51+00:00

I have a class called Person . It has the following attributes ; It

  • 0

I have a class called Person. It has the following attributes; It has 2 attributes, ID, and Telephone. 1 person can have many telephones, so you may see people with multiple ID’s below.

public ArrayList<Person> all(){

    p = new ArrayList<Person>();
    p.add(new Person(1,266763));
    p.add(new Person(1, 358643));
    p.add(new Person(2, 4667763));

    return p; 
}

There’s another class called PersonDB. and it will have a method called, findPersonWithTheTelephoneNumber(int telephone).

public void findPersonWithTheTelephoneNumber(int telephone) {
   Person pp = new Person();
   ArrayList<Person> personList = pp.all();

   // Now i want to find the Person object that will match the telephone number of these list of personList.


}

The personList, has 3-4 Person objects. I need to search the PersonArrayList and find the object that will match the Person object. How can i get this done ?

Note: i tried personList.contains(). But this doesn’t work.

  • 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-16T02:26:52+00:00Added an answer on June 16, 2026 at 2:26 am

    i tried personList.contains()

    Make sure you override Object.equals() and Object.hashCode() for Person class. But you have to have equality check on telephone number assuming telephone number unique. This would not be a solution but a workaround. Use bellum’s answer. Mark it as correct answer.

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

Sidebar

Related Questions

I have an Object called Person which has the following attributes; id , name
I have an object called Person that has the following properties: int id; Name
I have a very simple Person class that has a ivar called name (
I have a Model called Person and Person has multiple posts. When I want
I have a method that can be called if the person has a specific
Im having rather an annoying problem. I have a class called Person and a
I have a model called Person. I want User to inherit from Person. class
I have a class called Flamethrower which naturally has its own ammunition that is
I have a class called Property which has nothing but get -methods. All the
I have the following class Person: public class Person { public string Name {

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.