+ 1
How to compare 2 objects of same class in java?
class Account { public: double balance; String name; } Account first = Account(); first.name = "Hemant"; first.balance = 100000.0; Account second = Account(); second.name = "Hemant"; second.balance = 100000.0; I wanna check both fisrt ans second object containts the same data. How to do that?
7 Réponses
+ 2
Comparing objects directly is not allowed. But the solution is to compare the individual "properties" of both objects.
+ 2
you r welcome........whenever you face a problem search it on google.......u may get the solution
+ 2
You want someone else making your homework?
+ 1
thanks for stack overflow link
+ 1
sure dude
0
implement the comparable interface and override compareTo() method.