当前位置:网站首页>思考变量引起的巨大变化
思考变量引起的巨大变化
2022-07-02 18:23:00 【夏诗曼CharmaineXia】
变量在计算机编程中太常见了,以下两种5+6的代码写法就体现了不使用变量与使用变量的区别。
- 写法一:
public static void main(String[] args) {
System.out.println(5+6);
}
- 写法二:
public static void main(String[]args){
int a = 5;
int b = 6;
System.out.println(a+b);
}
变化一:有限到无限
写法一表现出来的是两个固定的数相加,写法二表现出来的是两个变量相加,从有限到无限体现在两个方面:
- 方面1:从固定的两个数相加到任意两个数相加
- 方面2:从两个数相加到任意个数相加
变化二:算法的封装
写法一表现出来打印的是5+6的结果,写法二表现出来打印的是a+b的结果。写法二有一个算法封装的思想在里头,加法是包括在算法内,因为加法也是对解题方案的准确而完整的描述。
变化三:加法的复用
写法二把加法做成了一个模板,任何需要加法的地方都可以复用这个模板。
写法二引入两个简简单单的变量a和b就产生了如此多的变化,如果有关于写法二的其他想法欢迎发表在评论中。
边栏推荐
- 【pytorch学习笔记】Tensor
- 注解开发方式下AutowiredAnnotationBeanPostProcessor的注册时机
- Advanced performance test series "24. Execute SQL script through JDBC"
- 思维意识转变是施工企业数字化转型成败的关键
- Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
- Learn the knowledge points of eight part essay ~ ~ 1
- 2022 compilation principle final examination recall Edition
- 教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 网络安全专家 NSE 5
- mysql备份后缀是什么_mysql备份还原
- Introduction to the paper | application of machine learning in database cardinality estimation
猜你喜欢
Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
Markdown基础语法
Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5
守望先锋世界观架构 ——(一款好的游戏是怎么来的)
What is 9D movie like? (+ common sense of dimension space)
Usage of ieda refactor
Stm32g0 USB DFU upgrade verification error -2
yolov3 训练自己的数据集之生成train.txt
论文导读 | 关于将预训练语言模型作为知识库的分析与批评
Codeworks 5 questions per day (1700 average) - day 4
随机推荐
Stm32g0 USB DFU upgrade verification error -2
Markdown基础语法
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
ORA-01455: converting column overflows integer datatype
二进制操作
开发固定资产管理系统,开发固定资产管理系统用什么语音
Introduction to the paper | application of machine learning in database cardinality estimation
Fastdfs installation
When converting from list to map, if a certain attribute may cause key duplication and exceptions, you can set the way to deal with this duplication
Tutoriel (5.0) 10. Dépannage * fortiedr * fortinet Network Security expert NSE 5
Page title component
Progress progress bar
Memory management of C
全志A33使用主线U-Boot
Reduce -- traverse element calculation. The specific calculation formula needs to be passed in and combined with BigDecimal
性能测试如何创造业务价值
中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖
The mybatieshelperpro tool can be generated to the corresponding project folder if necessary
Data dimensionality reduction principal component analysis
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径