当前位置:网站首页>思考变量引起的巨大变化
思考变量引起的巨大变化
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就产生了如此多的变化,如果有关于写法二的其他想法欢迎发表在评论中。
边栏推荐
- 全志A33使用主线U-Boot
- Use cheat engine to modify money, life and stars in Kingdom rush
- Tutoriel (5.0) 10. Dépannage * fortiedr * fortinet Network Security expert NSE 5
- C file input operation
- IEDA refactor的用法
- 使用CLion编译OGLPG-9th-Edition源码
- Talk about the design of red envelope activities in e-commerce system
- Golang:[]byte to string
- How to print mybats log plug-in using XML file
- ICDE 2023|TKDE Poster Session(CFP)
猜你喜欢

使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星

ICDE 2023|TKDE Poster Session(CFP)

Talk about the design of red envelope activities in e-commerce system

Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径

MySQL advanced learning summary 7: MySQL data structure - Comparison of hash index, AVL tree, B tree and b+ tree

Develop fixed asset management system, what voice is used to develop fixed asset management system

Compile oglpg-9th-edition source code with clion

Yunna | why use the fixed asset management system and how to enable it

新手必看,點擊兩個按鈕切換至不同的內容
![[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning](/img/54/8a18cd30e6186528599c0556b1ee3b.png)
[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning
随机推荐
[test development] software testing - concept
Microservice technology - distributed global ID in high concurrency
MySQL高级(进阶)SQL语句
GMapping代码解析[通俗易懂]
Learn the knowledge points of eight part essay ~ ~ 1
According to the atlas of data security products and services issued by the China Academy of information technology, meichuang technology has achieved full coverage of four major sectors
Markdown基础语法
以太网PHY层芯片LAN8720A简介
2022 compilation principle final examination recall Edition
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
Qpropertyanimation use and toast case list in QT
为什么要做企业固定资产管理系统,企业如何加强固定资产管理
潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
Emmet基础语法
Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出
Compile oglpg-9th-edition source code with clion
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
Digital scroll strip animation
C file input operation
Excel查找一列中的相同值,删除该行或替换为空值