Serialization #2



JavaBeans are classes that encapsulate many objects into a single object (the bean), and  they are serializable.

  • It provides a default, no-argument constructor.
  • It should be serializable and implement the Serializable interface.
  • It may have a number of properties which can be read or written.
  • It may have a number of “getter” and “setter” methods for the properties.


package com.chang;

public class StudentsBean implements 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;

Leave A Comment

Your email address will not be published. Required fields are marked *