Java three kinds of variable types comparison

1. Introduction variables

  • Member variable (class variables): it can be used to describe a property of the class
  • Local variables (method variables): Write in the member variables are local approach
  • Static variables: the static variable modified

2. The difference between the three comparison

img

3. thread-safety issues

Static variables: non-thread-safe. Examples of variables: Singleton (only one instance of an object exists) - non-thread safe, non-singleton - thread safe. Local variables: thread safe.

data

The difference between static variables, member variables, local variables

Static variables java thread-safety issues, the instance variables, local variables

Verbatim large column  https://www.dazhuanlan.com/2019/08/27/5d64b42b81bcb/


Guess you like

Origin www.cnblogs.com/petewell/p/11418188.html