当前位置:网站首页>Why use the static keyword when defining methods
Why use the static keyword when defining methods
2022-07-26 06:20:00 【Ant HJK】
First, let's talk about the benefits of static methods :
Used static After keyword method , This method is loaded into memory when the class is loaded and only loaded once
When using, you only need to access through the class name , There is no need to consume resources again to create
So when does it end , The memory will not be released until the end of the program
If the method is not applicable when it is created static What about keywords
If the method created is not static When decorating, the inventory duration of this method starts and ends with the call , And directly be JVM Recycling
secondly :
When to use static
If this method is used as a tool class , Declare as static, Unwanted new A formation used
Private methods defined in normal development still do not need to be declared static Of
边栏推荐
- [day_040421] calculate candy
- Ganglia installation and deployment process
- How to divide the disks under the devices and drives in win10 new computer
- Interpretation of TPS motion (cvpr2022) video generation paper
- nuxt 配置主题切换
- Taobao pinduoduo Tiktok 1688 Suning taote jd.com and other keyword search commodity API interfaces (keyword search commodity API interface, keyword search commodity list interface, classification ID s
- Mobile web
- PHP 多任务秒级定时器的实现方法
- Operating steps for uninstalling the mobile app
- 【Day_04 0421】计算糖果
猜你喜欢

YOLOv6:又快又准的目标检测框架开源啦

If introduced according to the open source framework

Acquisition of bidding information
![[day05_0422] C language multiple choice questions](/img/cb/0019ec819480bd9f52055e726b323a.png)
[day05_0422] C language multiple choice questions

输入5个学生的记录(每条记录包括学号和成绩), 组成记录数组, 然后按照成绩由高到低的次序输出. 排序方法采用选择排序

Code runner for vs code, with more than 40million downloads! Support more than 50 languages
![[(SV & UVM) knowledge points encountered in written interview] ~ phase mechanism](/img/19/32206eb6490c2a5a7a8e746b5003c1.png)
[(SV & UVM) knowledge points encountered in written interview] ~ phase mechanism

Mobile web

Leetcode:940. How many subsequences have different literal values

Amd zen4 game God u reached 208mb cache within this year, which is unprecedented
随机推荐
【Day_04 0421】进制转换
flex布局
[Oracle SQL] calculate year-on-year and month on month (column to row offset)
L. Link with Level Editor I dp
Leetcode:940. How many subsequences have different literal values
[day_010418] delete public string
Workflow activiti5.13 learning notes (I)
Leetcode:336. palindrome pair
How can machinery manufacturing enterprises do well in production management with the help of ERP system?
【BM2 链表内指定区间反转】
Latex merges multiple rows and columns of a table at the same time
【Day06_0423】C语言选择题
English sentence pattern reference exclusive Edition - attributive clause
C language explanation series - comprehensive exercises, guessing numbers games
【Day_06 0423】把字符串转换成整数
Calling mode and execution sequence of JS
Easycvr video square channel display and video access full screen display style problem repair
输入5个学生的记录(每条记录包括学号和成绩), 组成记录数组, 然后按照成绩由高到低的次序输出. 排序方法采用选择排序
Distributed | practice: smoothly migrate business from MYCAT to dble
Matlab vector and matrix