Java - Should private instance variables be accessed in constructors through getters and setters met

Posted by Yatendra Goel on Stack Overflow See other posts from Stack Overflow or by Yatendra Goel
Published on 2010-04-02T18:40:22Z Indexed on 2010/04/02 18:43 UTC
Read the original article Hit count: 425

Filed under:
|
|
|

I know that private instance variables are accessed through their public getters and setters method.

But when I generate constructors with the help of IDE, it initializes instance variables directly instead of initializing them through their setter methods.

Q1. So should I change the IDE generated code for constructors to initialize those instance variables through their setter methods.

Q2. If yes, then why IDE don't generate constructors code in that way?

© Stack Overflow or respective owner

Related posts about java

Related posts about oop