table of Contents:
What is Java Bean?
A standard class usually has four components:
- 1. All member variables need to be modified with the private keyword.
- 2. Write a pair of Get/Set methods for each member.
- 3. Write a no-argument constructor for the class.
- 4. Write a parameter construction method for the class. (All parameters)
How the IDEA editor uses shortcut keys to automatically generate construction methods
- According to the process, a class named sudent is generated, which contains two member variables, and both member variables need to be modified by the private keyword.
- Shortcut key (Alt+Insert) generates no-parameter construction method
Select the sudent class:
Press the shortcut key Alt+Insert to get the following interface:
select the blue class student:
- Shortcut key (Alt+Insert) to generate full parameter construction method
is similar to the above: the key point is to select student and all member variables after holding down Shift:
- (Alt+Ins) Generate member method:
select member variable (name):
Alt+Ins shortcut key to get the following interface:
select the member variable name:
finally get the get and set methods: the
same way you can get the get/ of the member variable age set method: