Created
March 27, 2021 16:32
-
-
Save wkdalsgh192/0a2a3073aaf355ccc01fdd60d1ed0d67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserBean { | |
// fields to construct a bean. Recommended to make all private in singleton design pattern. | |
private String name; | |
private int age; | |
private boolean male; | |
// bean must have its default constructor. | |
public UserBean() {} | |
public UserBean(String name, int age, boolean male) { | |
super(); | |
this.name = name; | |
this.age = age; | |
this.male = male; | |
} | |
// bean renew or return its data only through setter-getter methods | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
public boolean isMale() { | |
return male; | |
} | |
public void setMale(boolean male) { | |
this.male = male; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment