January 6, 2021 Now that I've learned about JavaBeans for the first time today, I'll briefly summarize what JavaBeans are.
Simply put, it's like a warehouse for storing data. A reusable software component written in Java, its technical specifications. Software components are classes, and JavaBeans are often used when manipulating data in web applications.
--Specify the class as public --Specify the property as private --Define a constructor with no arguments by specifying public --Prepare getter and setter methods to access properties --Packaging --The end of the class name is customarily a Bean --Implementing the java.io.Serializable interface, although not required
It is possible to prevent rewriting to Mr. Ito of the data. Since each data attribute is private, it cannot be accessed from the outside, and the data attribute cannot be rewritten unless the setter is called after creating an instance. (Protecting data attributes from the outside in this way is called encapsulation)
Misuse of the setter can easily break the encapsulation. Therefore, when using a setter, it is necessary to be careful that the correct value is set.
What are JavaBeans? Explanation of specifications, usage, and persistence Active engineers explain how to use JavaBeans [for beginners]
Recommended Posts