Java's javaBean shortcut key creates a construction method and get and set methods, encapsulation, plug-ins, idea


Construction method introduction

构造方法(构造器)
创建对象的时候,要执行的方法
格式
1、方法名与类名相同,大小写也需要一致
2、没有返回值类型,连void都没有
3、没有具体的返回值(不能由return语句带回结果数据)
构造方法的执行时机
在创建对象的时候,被调用执行
每创建一次对象,就会执行一次构造方法构造方法的作用
1、本质的作用: 创建对象
2、结合执行时机: 可以创建对象的时候,给对象中的数据初始化
构造方法的注意事项
1、一个类中,没有编写构造方法,系统将会提供一个[默认的][无参数]的构造方法
2、一个类中,如果手动编写了构造方法,系统将不会再提供那个默认的无参构造了
建议: 编写类的时候,无参构造,带参构造,全部手动给出
3、构造方法不允许手动调用


Shortcuts for creating empty and parameterized constructors

first step

Right-click where you need to create a construction method to open the operation panel and select GenerateOpen GeneratePanel.


second step

GenerateSelect ConstructorOpen Panel after opening Choose Fields to Initialize by Constructorthe panel.


third step

After opening Choose Fields to Initialize by Constructorthe panel, click Select Nonethe button to create a parameterless constructor.


the fourth step

After opening Choose Fields to Initialize by Constructor, select the required parameters in the panel, and click OKthe button to create a construction method with parameters.


Create shortcuts for get and set functions of member variables

first step

Right-click on the line where the construction method needs to be created to open the operation panel and select GenerateOpen GeneratePanel.


second step

Once the panel is open Generate, select Getter and SetterOpen Select Fields to Generate Getters and SettersPanel.


third step

After opening Select Fields to Generate Getters and Settersthe panel, select the member variables that need to be created getand setmethods, and click OK.


Generate required content using plugins

first step

Click Open Dashboard IDEAin the upper left corner Fileand select SettingsOpen SettingsDashboard.


second step

Once the panel is open Settings, select PluginsOpen PluginsPanel.


third step

PluginsThe panel has two tabs, and the right tab lists the installed plug-ins.


the fourth step

Click the tab on the left, enter in the input box ptg, after searching for the plug-in, click Installthe option to install the plug-in.


the fifth step

After installing the plugin, click OKit.


step six

Right-click where the content is needed to open the operation panel and click Ptg To JavaBeanto create content.

Guess you like

Origin blog.csdn.net/weixin_51157081/article/details/131871117