当前位置:网站首页>Classes and objects, methods and encapsulation
Classes and objects, methods and encapsulation
2022-06-12 04:59:00 【なんでもないゃ】
Use of variable length parameters : Note that the list of formal parameters of a method can use at most one variable length parameter , And the parameter is placed at the end ;
void setName(String...args){
for(int i = 0;i<args.length();i++){
System.out.println(args[]);
}
} Parameter passing :

Parameter is the parameter of method declaration , Arguments are parameters of method calls ;
Construction method : When there is no constructor in the class , It will call the parameterless constructor by default , But when there is a constructor in a class , Cannot call default parameterless constructor ;
heavy load : The number of parameter types is different , Independent of return value and parameter name ;
this: Represent the object being constructed in the construction method , Represent the variable being called in the member method ; Accessing member variables in constructor and member methods , The compiler will add... By default this keyword ;
When the local variable name is the same as the member variable name , Local variables are preferred , If you want to use member variables , Should be added before the member variable this. Prefix , Make sure that the variable is a member variable ;
Encapsulate how to implement : Set the property to private, And write the corresponding get、set Method , stay set Method to implement restrictions on attributes , Note that public Of , Implement encapsulation of attributes ;
边栏推荐
- [backtracking] backtracking to solve subset problems
- 加速训练之并行化 tf.data.Dataset 生成器
- Deploying a single node kubernetes cluster using rancher-2.5.5
- [cjson] precautions for root node
- 1006 next spread
- According to aiqicha, keep went public in Hong Kong and hit the "first share of online fitness"
- JS to determine whether it is the first time to browse the web page
- [backtracking method] backtracking method to solve the problem of Full Permutation
- Spatial distribution data of national multi-year average precipitation 1951-2021, temperature distribution data, evapotranspiration data, evaporation data, solar radiation data, sunshine data and wind
- [GIS tutorial] land use transfer matrix
猜你喜欢

How to count the total length of roads in the region and draw data histogram

JWT学习与使用

One dragon and one knight accompanying programmers are 36 years old

Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution

Bearpi IOT serial port transceiver 1- normal mode

@What happens if bean and @component are used on the same class?

L1-066 cat is liquid (5 points)

Chrome is amazingly fast, fixing 40 vulnerabilities in less than 30 days

2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)

2022 examination questions and simulation examination for crane driver (limited to bridge crane)
随机推荐
MySQL5.7.21 Build For ARM
Microsoft announces that it will discontinue support for older versions of visual studio
JWT學習與使用
Gavin teacher's perception of transformer live class - rasa dialogue robot project practice in the field of education agency mode and core component source code analysis under the microservice of educ
2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)
Pupanvr- establishment of development environment and diary, addition of some basic tool functions (3)
Google reinforcement learning framework seed RL environment deployment
kali下安装pycharm并创建快捷访问
LabVIEW关于TDMS和Binary存储速度
How to clear floating, and how does it work?
@What happens if bean and @component are used on the same class?
Pupanvr create project and management script (2)
Jwt Learning and use
What is reverse repurchase of treasury bonds? Is the reverse repurchase of treasury bonds safe?
CCF access control system
Parallélisation de l'entraînement accéléré TF. Données. Générateur de données
Pupanvr- an open source embedded NVR system (1)
2022“高考记忆” 已打包完成,请查收!
The third "World War" - chip defense, smokeless battlefield!
加速訓練之並行化 tf.data.Dataset 生成器