Statement: Most of the articles in this official account come from the author's daily study notes, and some articles are also reproduced from the Internet. If there is any infringement, please contact us to delete them. Please do not use the relevant technologies in the article t

Statement: Most of the articles in this official account come from the author's daily study notes, and some articles are also reproduced from the Internet. If there is any infringement, please contact us to delete it. Please do not use the relevant technologies in the article to engage in illegal testing. If all adverse consequences arise, they have nothing to do with the author of the article and this official account.

0x01 Create a new class

1, Create a new class, the class name is animal, disclose

2, add the attributes of the class, the color, the type is text type

3, add a method, sleep, public, return the text as: Sleeping

4, add another method, skin, public, return the text as: The color of the kitten we set

0x02 Call the class and method we wrote

1, declare a variable, kitten, type is animal

2, set the color of the kitten to white

3, call the two methods of sleeping and skin

 prompt information box (kitten.sleep ()) kitten. Color = "white" prompt information box (kitten.skin ())

4. Remember, when calling the method and member variables of the class, the method name is bracketed, and the member variable cannot be bracketed

0x03 Running effect


6 Follow Li

Welcome to follow the official account: Programmer Bar