当前位置:网站首页>Quick start to static class variables
Quick start to static class variables
2022-04-23 19:07:00 【19th line programmer】
Name of class variable : Static variables / Class variables / Class properties
Class attribute concept : It is an independent space belonging to class ( This space is created when the class is loaded ), Every object created by this class can operate on it ( share ).
Class variable definition and access :
Definition grammar :
//static It's a modifier , You can modify properties and methods
public static int totalNum = 0;
Access Syntax ( There are two ways to access ):
1, Directly access... By class name
2, Access... By object name
class Test {
// Class name . Class variables
// explain : Class variables are created as the class loads , So you can access... Even if you don't create an object instance .
public static void main(System[] args){
// Access... By class name
System.out.println(A.name);
A a = new A();
// Access... By object name
System.out.println(a.name);
}
}
class A {
// Class variables
String static name = " Xiao Ping ";
}
matters needing attention :
Access to class variables , The relevant access rights must be observed .
版权声明
本文为[19th line programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231904210171.html
边栏推荐
- Simple use of viewbinding
- Practice of Druid SQL and security in meituan review
- RPM package management
- 8266 obtain 18b20 temperature
- Esp01s with Arduino development environment
- 解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
- Machine learning theory (8): model integration ensemble learning
- About the operation of unit file reading (I)
- ESP32 LVGL8. 1 - bar progress bar (bar 21)
- [today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
猜你喜欢
Chondroitin sulfate in vitreous
解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
MySQL学习第五弹——事务及其操作特性详解
Keysight has chosen what equipment to buy for you
ESP32 LVGL8. 1 - slider slider (slider 22)
Practice of Druid SQL and security in meituan review
ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
Simplified path (force buckle 71)
【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
Machine learning theory (8): model integration ensemble learning
随机推荐
Nacos集群搭建和mysql持久化配置
Nacos作为服务注册中心
Using Visual Studio code to develop Arduino
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
Esp32 (UART event) - serial port event learning (1)
Sentinel规则持久化进Nacos
ESP32 LVGL8. 1 - checkbox (checkbox 23)
ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
在渤海期货办理开户安全吗。
After opening the original normal project, the dependency package displays red and does not exist.
Seata handles distributed transactions
ESP32 LVGL8. 1 - bar progress bar (bar 21)
Actual combat of Nacos as service configuration center
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
Resolution: cnpm: unable to load file \cnpm. PS1, because running scripts is prohibited on this system
Introduction to ROS learning notes (I)
从技术体系到商业洞察,中小研发团队架构实践之收尾篇