The way to create a constructor java

The constructor can complete the creation of the object and the initialization of the instance variables.
That is, the construction method is used to create the object and assign values ​​to the properties of the object.

There are two steps in the software creation construction method as follows:

Idea

1. Press the shortcut key: Fn+Alt+insert or Alt+insert

2. Click Constructor, the following page pops up

3. Select the required construction method and click OK

2. Eclipse

1. Right-click, the following screen will pop up, and the rest of the steps are shown in the blue part

2. Select the required construction method and click Generate

3. The construction method is shown in the figure below, where the super() method can be deleted

In addition, if you need get( ) and set( ) methods, you can also use the above method to create them.

Guess you like

Origin blog.csdn.net/m0_64206989/article/details/129233188