当前位置:网站首页>思考变量引起的巨大变化
思考变量引起的巨大变化
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就产生了如此多的变化,如果有关于写法二的其他想法欢迎发表在评论中。
边栏推荐
- 冒泡排序数组
- 虚拟机初始化脚本, 虚拟机相互免秘钥
- Golang concurrent programming goroutine, channel, sync
- Talk about the design of red envelope activities in e-commerce system
- SIFT特征点提取「建议收藏」
- 潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
- ICDE 2023|TKDE Poster Session(CFP)
- High frequency interview questions
- codeforces每日5题(均1700)-第四天
- Novice must see, click two buttons to switch to different content
猜你喜欢

教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 網絡安全專家 NSE 5

高级性能测试系列《24. 通过jdbc执行sql脚本》

全志A33使用主线U-Boot

云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统

Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent

Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出

Machine learning notes - time series prediction research: monthly sales of French champagne
![[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference

Tutoriel (5.0) 10. Dépannage * fortiedr * fortinet Network Security expert NSE 5

新手必看,点击两个按钮切换至不同的内容
随机推荐
Introduction to the paper | analysis and criticism of using the pre training language model as a knowledge base
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
Golang并发编程——goroutine、channel、sync
Talk about the design of red envelope activities in e-commerce system
9D电影是怎样的?(+维度空间常识)
ICDE 2023|TKDE Poster Session(CFP)
How to print mybats log plug-in using XML file
[test development] takes you to know what software testing is
The mybatieshelperpro tool can be generated to the corresponding project folder if necessary
[paper reading] Ca net: leveraging contextual features for lung cancer prediction
Introduction of Ethernet PHY layer chip lan8720a
Novice must see, click two buttons to switch to different content
[pytorch learning notes] tensor
2022.7.1-----leetcode. two hundred and forty-one
Excel查找一列中的相同值,删除该行或替换为空值
SIFT feature point extraction "suggestions collection"
Golang并发编程——goroutine、channel、sync
Emmet基础语法
使用CLion编译OGLPG-9th-Edition源码
[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning