java - Programming difference between POJO and Bean -
i have following 2 classes. can first 1 pojo class , second 1 bean class?
1) pojo class, since has getter , setter method, , member declared private
public class pojo { private int id; private string name; public int getid() { return id; } public string getname() { return name; } public void setid() { this.id = id; } public void setname() { this.name = name; } }
2) bean class - member variables private, has getters , setters , implements serializable
interface
public class bean implements java.io.serializable { private string name; private integer age; public string getname() { return this.name; } public void setname(string name) { this.name = name; } public integer getage() { return this.age; } public void setage(integer age) { this.age = age; } }
it has no-arg constructor.
only difference bean can serialized.
from java docs - http://docs.oracle.com/javase/7/docs/api/java/io/serializable.html
serializability of class enabled class implementing java.io.serializable interface. classes not implement interface not have of state serialized or deserialized. subtypes of serializable class serializable. serialization interface has no methods or fields , serves identify semantics of being serializable.
Comments
Post a Comment