+ 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?

10th Jun 2017, 1:03 PM
Hemant Makar
Hemant Makar - avatar
7 odpowiedzi
+ 2
Comparing objects directly is not allowed. But the solution is to compare the individual "properties" of both objects.
10th Jun 2017, 1:06 PM
Debargha Roy
Debargha Roy - avatar
+ 2
you r welcome........whenever you face a problem search it on google.......u may get the solution
10th Jun 2017, 1:37 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 2
You want someone else making your homework?
10th Jun 2017, 2:25 PM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 1
thanks for stack overflow link
10th Jun 2017, 1:28 PM
Hemant Makar
Hemant Makar - avatar
+ 1
sure dude
10th Jun 2017, 1:37 PM
Hemant Makar
Hemant Makar - avatar
0
implement the comparable interface and override compareTo() method.
10th Jun 2017, 1:59 PM
Ayush
Ayush - avatar