Search code examples
javaspringclassobjectjavabeans

Why aren't javabean features built into the root JAVA object?


I'm having a hard time understanding why javabeans are necessary and why they didn't just place the javabean features directly into the object class(root class) in java?

My understanding is you turn an object(instance) into a java bean and that way you get all the benefits like serializable and so on for all the objects in the bean. But if that is the case, why even have a separate bean class for this, why not just have built into the root object class?

Or am I not understand this?


Solution

  • You are not understanding it correctly. There is no actual Java class or interface that is a bean. It is merely a pattern, a convention.

    The bean convention is basically that a class will publicly expose some or all of its properties via public getXxx and setXxx methods, where XXX is the name of the property.

    Beans generally should be serializable, but any class can be serializable, and does not need to follow the bean convention.