当前位置:网站首页>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
边栏推荐
- Esp32 (UART ecoh) - serial port echo worm learning (2)
- Sentinel service fusing practice (sentinel integration ribbon + openfeign + fallback)
- Sentinel规则持久化进Nacos
- 12 examples to consolidate promise Foundation
- Seata handles distributed transactions
- mysql_linux版本的下载及安装详解
- ESP32 LVGL8. 1 - calendar (calendar 25)
- Use of kotlin collaboration in the project
- 机器学习理论基础篇--关于机器学习的一些术语
- Introduction to ROS learning notes (II)
猜你喜欢
Some records used by VS2010
Raspberry pie uses root operation, and the graphical interface uses its own file manager
Esp01s with Arduino development environment
该买什么设备,Keysight 给你挑好了
c#:泛型反射
解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
网络协议之:sctp流控制传输协议
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
mysql_linux版本的下載及安裝詳解
Practice of Druid SQL and security in meituan review
随机推荐
Esp32 (UART receiving and sending) - receiving and sending communication of serial port (4)
MVVM模型
Download xshell 6 and xftp6 official websites
binlog2sql 工具安装使用及问题汇总
Some records used by VS2010
Class loading process of JVM
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
c#:泛型反射
特征选择feature_selection--SelectKBest
SQL中函数 decode()与 replace()的用法
Actual combat of Nacos as service configuration center
Yyds dry goods inventory stringprep --- Internet string preparation
How can programmers quickly develop high-quality code?
static类变量快速入门
Sentinel规则持久化进Nacos
PyGame tank battle
12个例子夯实promise基础
Coolweather is revised and connected to the wind weather interface to realize the broken line diagram of temperature
Simple use of navigation in jetpack
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics