In-depth understanding of javaBean and Bean in java
JavaBean is a special class in Java that can encapsulate multiple objects into one object (bean).
Features are serializable, provide parameterless constructors, and provide access object properties of getter methods and setter methods.
The bean in the name is the idiomatic name for reusable software components used in Java.
advantage:
A bean can control whether its properties, events, and methods are exposed to other programs.
A bean can accept events from other objects, or generate events to other objects.
The properties of the bean can be serialized for future reuse.
JavaBean specification:
There is a public parameterless constructor
Attributes can be accessed via the get,set,is (can be used instead of get, on boolean properties) methods or other methods that follow specific naming specifications.
Serializable
Demo Code:
package bean; /** * Created by ryan on 17-8-1. */ public class PersonBean implements { private String name = null; private boolean deceased = false; public PersonBean(){ } public String getName(){ return name; } public void setName(final String value){ name = value; } public boolean isDeceased(){ return deceased; } public void setDeceased(final boolean value){ deceased = value; } }
package bean; /** * Created by ryan on 17-8-1. */ public class TestPersonBean { public static void main(String[] args){ PersonBean person = new PersonBean(); ("zhangsan"); (false); (()); (() ? "[the late]":"[Living]"); } }
The above is a detailed explanation of javabeans and beans. If you have any questions, please leave a message or go to the community of this site to communicate and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!