当前位置:网站首页>Think about the huge changes caused by variables
Think about the huge changes caused by variables
2022-07-02 19:34:00 【Charmaine Xia】
Variables are too common in computer programming , There are two kinds of 5+6 The code writing method of reflects the difference between not using variables and using variables .
- Writing a :
public static void main(String[] args) {
System.out.println(5+6);
}
- Write two :
public static void main(String[]args){
int a = 5;
int b = 6;
System.out.println(a+b);
}
Change one : Finite to infinite
Writing method 1 shows the addition of two fixed numbers , Writing method 2 shows the addition of two variables , From finite to infinite, there are two aspects :
- aspect 1: From adding two fixed numbers to adding any two numbers
- aspect 2: Add from two numbers to any number
Change 2 : Encapsulation of algorithms
As soon as the writing method is shown, what is printed is 5+6 Result , Writing method 2 shows that what is printed is a+b Result . Writing method 2 has an algorithm encapsulated idea in it , Addition is included in the algorithm , Because addition is also an accurate and complete description of the solution .
Change three : Multiplexing of addition
Writing method 2 makes addition into a template , This template can be reused wherever addition is required .
Writing 2 introduces two simple variables a and b There have been so many changes , If you have other ideas about writing method 2, please post them in the comments .
边栏推荐
- Chic Lang: completely solve the problem of markdown pictures - no need to upload pictures - no need to network - there is no lack of pictures forwarded to others
- 使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星
- 《代碼整潔之道》讀書筆記
- 股票证券公司排名,有安全保障吗
- Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出
- Microservice technology - distributed global ID in high concurrency
- SIFT feature point extraction "suggestions collection"
- Reading notes of "the way to clean structure" (Part 2)
- Chapter 7 - class foundation
- Advanced performance test series "24. Execute SQL script through JDBC"
猜你喜欢
线程应用实例
[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)
xml开发方式下AutowiredAnnotationBeanPostProcessor的注册时机
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
Machine learning notes - time series prediction research: monthly sales of French champagne
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
AcWing 342. 道路与航线 题解 (最短路、拓扑排序)
Tutorial (5.0) 10 Troubleshooting * fortiedr * Fortinet network security expert NSE 5
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
随机推荐
MySQL表历史数据清理总结
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
Implementation of 452 strcpy, strcat, StrCmp, strstr, strchr
高级性能测试系列《24. 通过jdbc执行sql脚本》
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 網絡安全專家 NSE 5
Yunna | why use the fixed asset management system and how to enable it
AcWing 1127. 香甜的黄油 题解(最短路—spfa)
Bubble sort array
Fastdfs installation
Data dimensionality reduction factor analysis
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
Notes de lecture sur le code propre
MySQL
Digital scroll strip animation
GMapping代码解析[通俗易懂]
SIFT特征点提取「建议收藏」
函数高阶-柯里化实现
Is there any security guarantee for the ranking of stock and securities companies
AcWing 181. 回转游戏 题解(搜索—IDA*搜索)
AcWing 903. 昂贵的聘礼 题解(最短路—建图、dijkstra)