how do i compare an object based on two fields

Student object


i want to compare student object with combination first name and last name
how many ways we can what is the best approach to do it?
Who is Participating?
CEHJConnect With a Mentor Commented:
Then you would implement equals() based on the equals of both fields
What do you mean (in plain English) by 'compare'?
srikoteshAuthor Commented:
I may have 100 students object
I have to compare and I have to take unique objects
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Student should already have an ID. Does it not have one?
Incidentally, i asked my last question because 'comparing' in Java suggests sorting, not examining difference or equality. The latter is implemented by equals()

If you don't have an ID, you should ask yourself
a. what happens if you have two students called "John Smith"?
b. what happens if you have two students called "John Smith" at the same address (improbable but not impossible)
srikoteshAuthor Commented:
i want to compare an object based on two fields
it doesn't have any unique id
by combinatin of two fieds it will be a unique

for sample i took student object

if i have 100 objects those 100 should be unique objects only
awking00Connect With a Mentor Commented:
You may want to use equalsIgnoreCase() if you consider John = JOHN and/or Smith = SMITH
All Courses

From novice to tech pro — start learning today.