In Java classes, except constants declared as static and public, general object data scopes are declared as private. In this way, the attributes of the object will not be changed at will, and debugging will be much more convenient: In the public method of the class, you can see where the attribute value is changed by adding a call stack. Data declared as private is generally not allowed to write some set and get methods. Powerful eclipse provides us with the ability to quickly generate the set and get methods, directly:
Step 1: Right-click the declared class and select Source:
Step 2: Select generate getters and setters:
Step 3: Configure as needed, such as location and order. Select OK:
In the previous article, eclipse usage and tips 5: generate instructions 2:
Http://blog.csdn.net/ts1122/article/details/8798127
In the next article, eclipse usage and technique 7: automatically generate get and Set Method 2:
Http://blog.csdn.net/ts1122/article/details/8893263