Bean類別定義.
下列是一個來自 Wikipedia 的Bean.類別範例, 其中含有兩個 Property : name 與 deceased. 更多關於 Bean 的命名規則可參考 oracle 的解釋
package beans; .*/ public class PersonBean implements java.io.Serializable { private String name = null; private boolean deceased = false; /** No-arg constructor (takes no arguments). */ public PersonBean() { } /** * Property name (note capitalization) readable/writable.*/ public String getName() { return name; } /** * Setter for property name.* @param NAME */ public void setName(final String NAME) { name = NAME; } /** * Getter for property "deceased" * Different syntax for a boolean field (is vs. get) */ public boolean isDeceased() { return deceased; } /** * Setter for property deceased.* @param DECEASED */ public void setDeceased(final boolean DECEASED) { deceased = DECEASED; } } |