当前位置:网站首页>Static domain and static method
Static domain and static method
2022-07-01 01:52:00 【Hades hadir】
Static domain
class Employee {
private static int nextId = 1;
private int id;
}
- Each employee object has its own id Domain , But all instances of this class share one nextId Domain
- namely , If there is 1000 individual Employee Class object , Then there are 1000 Instance fields Id, But there is only one static domain nextId
- Even if there is no employee object , Static domain nextId Also exist
- Static fields belong to classes , Does not belong to any independent object
- In most object-oriented programming languages , Static fields are called class fields
static const
- Very few static variables , But static constants are often used .
Static methods
- A method that cannot perform an operation on an object
Static methods don't have this Parameter method
- Static methods cannot access instance domains , But you can access static domains in your own classes
public static int getNextId(){
return nextId; //return static field
}
边栏推荐
猜你喜欢

关于白盒测试,这些技巧你得游刃有余~
![[fundamentals of wireless communication-15]: illustrated mobile communication technology and application development-3-overview of digital communication 2G GSM, CDMA, 3G wdcma/cdma200/td-scdma, 4G LTE](/img/22/1efa444220131359b06005f597c9db.png)
[fundamentals of wireless communication-15]: illustrated mobile communication technology and application development-3-overview of digital communication 2G GSM, CDMA, 3G wdcma/cdma200/td-scdma, 4G LTE

(翻译)实时内联验证更容易让用户犯错的原因

How to maintain efficient collaboration in remote office and achieve stable growth of projects | community essay solicitation

Selenium经典面试题-多窗口切换解决方案

How does ZABBIX configure alarm SMS? (alert SMS notification setting process)

(翻译)使用眉状文本提高标题点击率

修复表中的名字(首字符大写,其他小写)

Unknown database connection database error

亲测有效,快速创建JMeter桌面快捷方式
随机推荐
P6773 [NOI2020] 命运(dp、线段树合并)
视频教程 | 长安链推出系列视频教程合集(入门)
Working for eight years as a programmer, but with a salary of three years after graduation, it's too late to be enlightened again
【agora】用户管理
Video tutorial | Chang'an chain launched a series of video tutorial collections (Introduction)
【2022年】江西省研究生数学建模方案、代码
Ks009 implementation of pet management system based on SSH
More pragmatic in business
How does the property send a text message to the owner?
With one-stop insight into industry hot spots, the new function "traffic market" of feigua data station B is launched!
医疗HIS行业短信发送解决方案
org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms)错误解决
短信在企业中的应用有哪些?
PHP converts two-dimensional array elements into key value pairs
Check the disk usage of MySQL database
测试必备工具—Postman实战教程
CorelDRAW 2022中文精简64位直装版下载
远程办公如何保持高效协同,实现项目稳定增长 |社区征文
[content of content type request header]
思特奇加入openGauss开源社区,共同推动数据库产业生态发展