+ 1
Why not just use a1.name?
Refering to the first example in this lesson. Simply accessing the object's variable or attribute through . seems simpler and faster, and I fail to visualize how using equals is better..
4 Answers
+ 6
Please clarify with example
+ 5
asker @ace
+ 1
@ace that's exactly how it should be (even the overuse of getter/setter part) how is this controversial? the only thing not aligning good with reality is the overuse getter/setter part. however that's mostly due to (imo) wrong definition of unit testing.
+ 1
Thanks Ace! Great answer.
My question mainly revolved around the futility of using equals, and as I'm guessing from your answer, I wasn't wrong. But you're right, in most big projects, private variables with user-defined Getters and Setters are preferable. It is situational though.
My answer is here; equals isn't the only way (except for strings in certain cases). Thanks!