A member of one class of property (c)

1. The properties of the class

  ♥ syntax:

    Modifier Data type attribute name = initial value;

  Note 1: Modifiers

    √ commonly used modifiers have rights: private, default, protected, public

    √ other modifiers: static, final

  Note 2: Data Type

    √ any basic data type (e.g., int boolean, char), or any ren reference data types.

  Note 3: attribute name

    √ belong identifier, in line with naming variables can be named

  Examples: public class Person {

       private int age;

       public  String name = "Lisi";

    }

2. Classification of variables: local variables and member variables

  • In vitro methods, variables declared within the class known as member variables.

  • variable called local variables declared inside the method body.

 

   • Note: similarities and differences in terms of initial values:

      The same: have a lifecycle

      Different: In addition to the local variable parameter, showed initialization.

 

Guess you like

Origin www.cnblogs.com/lingtiaoti/p/12324468.html