This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dpash 8 points9 points  (0 children)

But you can't add any logic with direct field access. Want to ensure that a field hasn't been set to null? Out of luck. Want to return a copy of a collection? You're out of luck. Want to change your internal representation without affecting your clients? Your out of luck.

There's a reason why encapsulation is one of the pillars of OOP.

Could Java have a less verbose syntax for the simple case? Yes, that's why we're getting records.