当前位置:网站首页>校园兼职平台项目反思
校园兼职平台项目反思
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));
}
边栏推荐
- 【愚公系列】2022年08月 Go教学课程 036-类型断言
- Will oracle cardinality affect query speed?
- LeetCode刷题第17天之《3 无重复字符的最长子串》
- 【FPGA】day21-移动平均滤波器
- typedef defines the structure array type
- 机器学习中什么是集成学习?
- When EasyCVR is connected to the GB28181 device, what is the reason that the device is connected normally but the video cannot be played?
- 2022-08-10 The sixth group Hiding spring study notes
- Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
- 蹭个热度-请勿打开
猜你喜欢
Basic understanding of MongoDB (2)
作业8.10 TFTP协议 下载功能
E-commerce project - mall time-limited seckill function system
LeetCode Brush Questions Day 11 String Series "58 Last Word Length"
Use jackson to parse json data in detail
QueryDet: Cascading Sparse Query Accelerates Small Object Detection at High Resolution
Qnet Weak Network Test Tool Operation Guide
机器学习是什么?详解机器学习概念
"98 BST and Its Verification" of the 13th day of leetcode brushing series of binary tree series
Graphical LeetCode - 640. Solving Equations (Difficulty: Moderate)
随机推荐
Graphical LeetCode - 640. Solving Equations (Difficulty: Moderate)
CTO said that the number of rows in a MySQL table should not exceed 2000w, why?
【FPGA】day20-I2C读写EEPROM
The impact of programmatic trading and subjective trading on the profit curve!
MYSQLg advanced ------ clustered and non-clustered indexes
【FPGA】abbreviation
【FPGA】day18-ds18b20实现温度采集
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
AI+医疗:使用神经网络进行医学影像识别分析
AI + medical: for medical image recognition using neural network analysis
学编程的第十三天
[C Language] Getting Started
The custom of the C language types -- -- -- -- -- - structure
typedef定义结构体数组类型
C# 一周入门高级编程之《C#-LINQ》Day Four
【FPGA】名词缩写
什么是机器强化学习?原理是什么?
机器学习中什么是集成学习?
es-head插件插入查询以及条件查询(五)
A simple JVM tuning, learn to write it on your resume