当前位置:网站首页>校园兼职平台项目反思
校园兼职平台项目反思
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));
}

边栏推荐
- I didn't expect MySQL to ask these...
- 机器学习中什么是集成学习?
- What problems should we pay attention to when building a programmatic trading system?
- LeetCode Brush Questions Day 11 String Series "58 Last Word Length"
- 【FPGA】设计思路——I2C协议
- leetcode刷题第13天二叉树系列之《98 BST及其验证》
- LeetCode热题(12.买卖股票的最佳时机)
- QueryDet: Cascading Sparse Query Accelerates Small Object Detection at High Resolution
- MYSQLg高级------回表
- uni-app - city selection index list / city list sorted by A-Z (uview component library IndexList index list)
猜你喜欢

【FPGA】设计思路——I2C协议

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

STC8H开发(十五): GPIO驱动Ci24R1无线模块

LeetCode刷题第16天之《239滑动窗口最大值》

Homework 8.10 TFTP protocol download function

A simple JVM tuning, learn to write it on your resume

The development of the massage chair control panel makes the massage chair simple and intelligent

【FPGA】day21- moving average filter

Use jackson to parse json data in detail

Multi-serial port RS485 industrial gateway BL110
随机推荐
Redis老了吗?Redis与Dragonfly性能比较
What is ensemble learning in machine learning?
STC8H开发(十五): GPIO驱动Ci24R1无线模块
"110 Balanced Binary Tree Judgment" in leetCode's 14-day binary tree series
程序化交易改变了什么?
你不知道的 console.log 替代品
QueryDet: Cascading Sparse Query Accelerates Small Object Detection at High Resolution
Use jackson to parse json data in detail
LeetCode刷题第16天之《239滑动窗口最大值》
Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
FTP错误代码列表
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
MYSQLg高级------回表
The "top pillar" slides, and new growth is extremely difficult to shoulder the heavy responsibility. Is Ali "squatting" to jump higher?
高度塌陷问题的解决办法
typedef defines the structure array type
Detailed explanation of VIT source code
A simple JVM tuning, learn to write it on your resume
Getting Started with Raspberry Pi (5) System Backup
Leetcode 669. 修剪二叉搜索树