I have one POJO class(Java bean class), it has two
variables for that it has setters and getters. Now i have
created two objects for that class and i have set the data
for those variables through this two objects. Now question
is i want check whether those two objects have same data or
not, for this write a program? Thanks, Bose.

Answer Posted / murli

override equals method from object class and have the comparison logic inside that.Also override hashcode method..
Now pBeanOne.equals(pBeanTwo) will give you the result

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between the paint() and repaint() methods?

795


Does substring create a new object?

745


why Interface used?

733


Why map is used in java?

792


What are implicit objects in java?

746


What is a nullable field?

768


What are the types of arrays in java?

816


How can we make sure main() is the last thread to finish in java program?

931


What is singleton class example?

790


What is widening and narrowing in java? Discuss with an example.

765


Explain about fail fast iterators in java?

785


Do we need to manually write Copy Constructor?

784


How are multiple inheritances done in Java?

847


Difference between ‘>>’ and ‘>>>’ operators in java?

871


How can we create a thread in java?

785