Adding attributes to the class is the
same as defining ordinary variables
Use the class to generate objects.
Class name variable name = new class name();
copy the code
In the main function of another file,
instantiate the class according to the format to get an object
Assign values to the attributes of the
object Object name. Attribute = value;
copy the code for
example,
lion toy. price = 10
lion toy. color = "red"
Get the property value of the
object Object. Property name
Copy code
Defining the object method The
method should define the
public void method name in the class () { what the method does, what the method does 2 }
Copy code
Object call method
Author: ifubing
link: https: //juejin.im/post/6893709775515713543/
Source: Nuggets
copyright reserved by the authors. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.