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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:45:53+00:00 2026-06-04T10:45:53+00:00

I have an ArrayList which contains data like profId, firstname, lastname, age. Now I

  • 0

I have an ArrayList which contains data like profId, firstname, lastname, age.

Now I have a lastname and firstname, which gets from user form side. Now I want to compare them with an ArrayList. If both match, I want to retrieve “respective profId”.

e.g arraylist contains data like

profId lastname fistname age

1 roy sam 25

2 ryob arnav 30

Now user will type lastname and firstname as roy and sam respectively. I will get this data by their getter methods.

Now, how should I compare these 2 names with the ArrayList so that I will get the perfect profid of him as:

‘1’.

I am trying to compare by this way.

//  existPatList is arraylist patfamily is object of Family from where I will get users value

for(Family p : existPatList) {
    System.out.println("Last name" +p.getLastName());             
    System.out.println("First name"+p.getFirstName());
    if(p.getLastName().equalsIgnoreCase(patFamily.getLastName())) {
        System.out.println("got it");       
    }
}

How can I solve this 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-04T10:45:55+00:00Added an answer on June 4, 2026 at 10:45 am

    Use a && in your if condition with both firstName and lastName.

    for(Family p : existPatList) {
       System.out.println("Last name" +p.getLastName());             
       System.out.println("First name"+p.getFirstName());
       if(p.getFirstName().equalsIgnoreCase(patFamily.getFirstName()) && p.getLastName().equalsIgnoreCase(patFamily.getLastName())) {
           System.out.println("got it");       
       }
    }
    

    To get profId replace your line:

    System.out.println("got it");
    

    with

    System.out.println(p.getProfId); //or do whatever you wanna do with profId
    

    I consider here the you getters also has a get method for profId, that is getProfId()

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

Sidebar

Related Questions

I have an (access) database table which contains data I would like to populate
I have a database column which contains varchar data type. I would like to
I have an arraylist arr which contains a series of number, like 07, 52,
I have an ArrayList which contains cutomer name details. In my JSP I am
I have an ArrayList called account which contains Strings. I'm trying to write a
I have an ArrayList in Java, which contains Objects, these Objects are made of
I have a list box control in my form which contains the paths of
I have an ArrayList which contains duplicate values at diff diff index. for example
I have a arraylist(eg.CustInfo) which contains a collection of objects(Cust_details,Cust_Auth) for java classes, which
I have a listview which is filled with data form sqlitedatabase. A list-view element

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.