java小技巧-idea快速创建get、set、toString

有朋友私信问到了。这个技巧还是很重要的,说一下。

需要idea编辑器,想快速生成下列的模板:

package pojo;

import java.util.Date;

public class AdminInfo {

    private Integer adminId ;
    private String adminName;
    private String adminPwd;
    private Integer roleId;
    private Integer adminState;
    private Date adminCtime;
    private Date adminMtime;

    public AdminInfo() {
    }

    public Integer getAdminId() {
        return adminId;
    }

    public void setAdminId(Integer adminId) {
        this.adminId = adminId;
    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public String getAdminPwd() {
        return adminPwd;
    }

    public void setAdminPwd(String adminPwd) {
        this.adminPwd = adminPwd;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public Integer getAdminState() {
        return adminState;
    }

    public void setAdminState(Integer adminState) {
        this.adminState = adminState;
    }

    public Date getAdminCtime() {
        return adminCtime;
    }

    public void setAdminCtime(Date adminCtime) {
        this.adminCtime = adminCtime;
    }

    public Date getAdminMtime() {
        return adminMtime;
    }

    public void setAdminMtime(Date adminMtime) {
        this.adminMtime = adminMtime;
    }

    @Override
    public String toString() {
        return "AdminInfo{" +
                "adminId=" + adminId +
                ", adminName='" + adminName + '\'' +
                ", adminPwd='" + adminPwd + '\'' +
                ", roleId=" + roleId +
                ", adminState=" + adminState +
                ", adminCtime=" + adminCtime +
                ", adminMtime=" + adminMtime +
                '}';
    }
}

首先声明好所有变量,这个要手写

package pojo;

import java.util.Date;

public class AdminInfo {

    private Integer adminId ;
    private String adminName;
    private String adminPwd;
    private Integer roleId;
    private Integer adminState;
    private Date adminCtime;
    private Date adminMtime;

    public AdminInfo() {
    }

}

调用快捷键Alt+Insert(Insert在笔记本键盘F12旁边,外接长键盘Back右边)

java小技巧-idea快速创建get、set、toString_第1张图片

 选中getter and setter 

java小技巧-idea快速创建get、set、toString_第2张图片

摁住shift,点击最后一个变量即可全部选中,再点ok生成。

java小技巧-idea快速创建get、set、toString_第3张图片

 toString也同理生成。


以后也会分享实用的小技巧。比如如何快速找到合适的目标检测图片集、如何水一个网页用于大学生竞赛等。

你可能感兴趣的:(java,java,开发语言)