当前位置:网站首页>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
边栏推荐
- Recyclerview control list item layout match_ Fundamental principle of parent attribute invalidation
- JVM的类加载过程
- Using bafayun to control the computer
- Codeforces Round #784 (Div. 4)
- ESP32 LVGL8. 1 - img picture (IMG 20)
- 迁移学习进阶
- [today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
- The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
- The difference between ordinary inner class and static inner class
- Download xshell 6 and xftp6 official websites
猜你喜欢

Machine learning practice - naive Bayes

2022.04.23 (the best time for lc_714_to buy and sell stocks, including handling charges)

redis优化系列(三)解决主从配置后的常见问题

From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure

OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!

12 examples to consolidate promise Foundation

ESP32 LVGL8. 1 - checkbox (checkbox 23)

c#:泛型反射

ESP32 LVGL8. 1 - arc (arc 19)

FTP, SSH Remote Access and control
随机推荐
Chondroitin sulfate in vitreous
【C语言进阶11——字符和字符串函数及其模拟实现(2))】
ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
Recyclerview control list item layout match_ Fundamental principle of parent attribute invalidation
ESP32 LVGL8. 1 - textarea text area (textarea 26)
ESP32 LVGL8. 1 - bar progress bar (bar 21)
C: generic reflection
SQL中函数 decode()与 replace()的用法
Disable Ctrl + Alt + Del
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
Druid SQL和Security在美团点评的实践
解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
Esp32 (UART receiving and sending) - receiving and sending communication of serial port (4)
在渤海期货办理开户安全吗。
Use of content provider
Nacos cluster construction and MySQL persistence configuration
mysql_linux版本的下载及安装详解
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
程序员如何快速开发高质量的代码?
RPM包管理