当前位置:网站首页>校园兼职平台项目反思
校园兼职平台项目反思
2022-08-11 03:52:00 【沐风游云】
一、用IO流时一定要先序列化再反序列化
二、使用ArrayList集合add方法追加数据时会将前面的数据覆盖成新加入的数据
解决方法:在循环体内new ArrayList集合
三、定义实体类参数类型时,考虑后续是否会出现输入类型不一致错误
解决方法:直接定义成String类型,需要什么类型再转。如:String转int用Integer.parseInt(str)等。
四、传参问题
1、如果传递的是基本类型,那么传过来的就是这个参数的一个副本,也就是这个原始参数的值,如果在函数中改变了副本的值不会改变原始的值。
2、如果传递的是引用类型,那么传过来的就是这个引用参数的副本,这个副本存放的是参数的地址。如果在函数中没有改变这个副本的地址,而是通过地址改变改变了地址指向的值,那么在函数内的改变会影响到传入的参数。
3、如果在函数中改变了副本的地址,如当执行如a=其他对象,a=new等赋值操作时,实际上是将a指向新的位置,那么函数外的原值不改变。
传递参数的两种方式:
1、值传递
public static void fun(int x){
x=100;
System.out.println("x="+x);
}
public static void main(String[] args) {
int a=10;
fun(a);
System.out.println("a="+a);
}

2、引用传递
public static void test(int[] newarray){
newarray=new int[]{
10,20,30};
}
public static void main(String[] args) {
int[]array={
1,2,3};
test(array);
System.out.println(Arrays.toString(array));
}

边栏推荐
- C语言 recv()函数、recvfrom()函数、recvmsg()函数
- C language recv() function, recvfrom() function, recvmsg() function
- uni-app - 城市选择索引列表 / 通过 A-Z 排序的城市列表(uview 组件库 IndexList 索引列表)
- .NET 服务注册
- A simple JVM tuning, learn to write it on your resume
- 【FPGA】day21- moving average filter
- The "top pillar" slides, and new growth is extremely difficult to shoulder the heavy responsibility. Is Ali "squatting" to jump higher?
- C# 一周入门高级编程之《C#-LINQ》Day Four
- uni-app - 获取汉字拼音首字母(根据中文获取拼音首字母)
- 【FPGA】名词缩写
猜你喜欢

【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口

【愚公系列】2022年08月 Go教学课程 036-类型断言

QueryDet:级联稀疏query加速高分辨率下的小目标检测

机器学习怎么学?机器学习流程

LeetCode Brush Questions Day 11 String Series "58 Last Word Length"

"104 Maximum Depth of Binary Trees" in LeetCode's Day 12 Binary Tree Series

Qnet弱网测试工具操作指南

多串口RS485工业网关BL110

【FPGA】day18-ds18b20实现温度采集

【FPGA】名词缩写
随机推荐
元素的BFC属性
Read the article, high-performance and predictable data center network
What is Machine Reinforcement Learning?What is the principle?
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
.NET自定义中间件
Getting Started with Raspberry Pi (5) System Backup
The FTP error code list
高校就业管理系统设计与实现
【愚公系列】2022年08月 Go教学课程 036-类型断言
How can users overcome emotional issues in programmatic trading?
浅析一下期货程序化交易好还是手工单好?
Is there any way for kingbaseES to not read the system view under sys_catalog by default?
Will oracle cardinality affect query speed?
UNI-APP_iphone bottom safe area
The impact of programmatic trading and subjective trading on the profit curve!
【Yugong Series】August 2022 Go Teaching Course 036-Type Assertion
我的 archinstall 使用手册
机器学习可以应用在哪些场景?机器学习有什么用?
I didn't expect MySQL to ask these...
Build Zabbix Kubernetes cluster monitoring platform