1) How to construct a class
① "Construct Method", also known as "constructor", when an object is created, its construction method is automatically called. The constructor method is the same as the class name, with no return value.
② if the class does not have a constructor defined, theJava compiler automatically gives it a "default constructor" without parameters at compile time. If a class provides a custom construction method, the default construction method is no longer provided by the system.
③ A class can have more than one constructor, and multiple constructors are distinguished by parameters.
(2) class initialization block
You can use "{" and "}" in your class toenclose the statement directly as a member of the class. This "No Name" member of the class is used to initialize the fields of the class.
(3) The default value specified when executing the class member definition or the initialization block of the class, exactly which one you want to see is "in front".
Using the class defined in the previous page slide, the following code outputs what the result is