Normally it is a good practice to have class variables declared as private and use non private “getter and setter” methods to access them. This is otherwise called as “Data Encapsulation” in Object Oriented Programming.
NetBeans provides a way to automatically generate getters and setters of your class variables. It is fast and efficient. Here are the steps.