The difference between static variables and non-static variables is as follows: Memory allocation A static variable exists in memory when the application is initialized, and does not die until the program of the class it is running ends. Memory is not allocated until a static variable needs to be instantiated. 2. Life cycle The static variable life cycle is the existence period of the application; The existence period of a non-static variable depends on the existence period of the instantiated class. 3. Calling method Static variables can only be called by "class.static variable name", and instances of the class cannot be called; Non-static variables can be accessed directly through the instantiated class name when the class in which the variable is located is instantiated. 4. Sharing method Static variables are global variables that are shared by instance objects of all classes, that is, an instance changes the value of a static variable, and other similar instances read the changed value; Non-static variables are local variables that are not shared. 5. Access method Static members cannot access non-static members; Non-static members can access static members.
The difference between static variables and non-static variables in java
- Deep analysis of dry goods-ocr recognition process
- VS2013 code editor input Chinese into garbled question mark ???
- App performance test and weak network test
- # R学习笔记5 Definition and use of functions in R
- Spring ioc
- Mongodb cluster introduction to build mode using mlaunch and m
- Summary of Makefile related
- Python3 learning 2 (page through the Baidu search results)
- Tencent Cloud Live (Starter Edition) Quick Integration
- 1004 Grade Ranking (20 points)
- C++ brushing the universal head file
- A summary of some of the issues encountered during appium study notes
- AKKA's JAVA-TCP implementation
- Ubuntu16.04 win 10 dual system installation
- Bedside notes of tensorflow learning (a)
- 1023 JiaoZhu and CS
- Java basic programming - basic syntax
- [android source diary] - Why is the main thread of android not dead because of the infinite loop inside Looper.loop()?
- FreeRTOS (13) --- FreeRTOS lists and list items
- Spring cloud zuul upload file garbled