JavaBean

Quick TL;DR

  • JavaBean is a standard meaning it needs to adhere to the following conventions:

    • All properties are private (use getters/setters)

    • A public no-argument constructor

    • Implements Serializable interface

//SOURCE: https://www.tutorialspoint.com/jsp/jsp_java_beans.htm
package com.tutorialspoint;

public class StudentsBean implements java.io.Serializable {
   private String firstName = null;
   private String lastName = null;
   private int age = 0;

   public StudentsBean() {
   }
   public String getFirstName(){
      return firstName;
   }
   public String getLastName(){
      return lastName;
   }
   public int getAge(){
      return age;
   }
   public void setFirstName(String firstName){
      this.firstName = firstName;
   }
   public void setLastName(String lastName){
      this.lastName = lastName;
   }
   public void setAge(Integer age){
      this.age = age;
   }
}

Last updated