当前位置:网站首页>The difference between calling by value and simulating calling by reference
The difference between calling by value and simulating calling by reference
2022-07-03 15:54:00 【Zhangjian Tianya 2.0】
First :
Basic data type :8 Kind of byte short int long (4 Kind of ) float double( floating-point ) boolea( Boolean type ) char( Character type )
Reference data type :class,interface,array Arrays and so on
The reference data type must be stored in the heap , But its variable name is stored in the stack, storing a lot of information about the data in the heap
When making array names equal directly , Or let class,interface Examples created , When making the examples equal , It is equivalent to assigning its addresses together : When the A When the example is operated , In fact, it will be right B Example to operate , The relationship between the two is similar to that in the figure C and D The relationship between
But when the basic data type is assigned , Is value passing reference ,
int A=30;
int B=A;
B=20;
For B Assignment does not affect A Value
int [] A=new int[3];// A piece of memory is created in the stack memory Store A And point to three pieces int Heap memory of array memory address
int [] B =A;
A[0]=30;// here B[0] The value of 30
// A memory is created in the stack memory to store variables B And will be A The address of is assigned to B among , Then in the heap memory ,A and B Point to and execute the same memory
边栏推荐
- Custom annotation
- MongoDB 的安装和基本操作
- 利用MySQL中的乐观锁和悲观锁实现分布式锁
- 秒杀系统3-商品列表和商品详情
- Digital image processing -- popular Canny edge detection
- UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
- 如何使用 @NotNull等注解校验 并全局异常处理
- Detailed explanation of four modes of distributed transaction (Seata)
- Visual host system design and development (Halcon WinForm)
- Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
猜你喜欢
Principles of several common IO models
“用Android复刻Apple产品UI”(3)—优雅的数据统计图表
【Proteus仿真】74HC595+74LS154驱动显示16X16点阵
App mobile terminal test [3] ADB command
请做好3年内随时失业的准备?
Microservice sentinel flow control degradation
Jvm-09 byte code introduction
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
Introduction series of software reverse cracking (1) - common configurations and function windows of xdbg32/64
随机推荐
Detailed explanation of four modes of distributed transaction (Seata)
Redis高可用与持久化
The difference between RAR and zip files
Jvm-08-garbage collector
Tensorflow realizes verification code recognition (I)
找映射关系
The wonderful use of do{}while()
Visual upper system design and development (Halcon WinForm) -5 camera
首发!!lancet饿了么官方文档
Tensorflow realizes verification code recognition (III)
Principles of several common IO models
Summary of JVM knowledge points
Get the executable path through the process PID (queryfullprocessimagename)
Microservice API gateway
Large CSV split and merge
Unityshader - materialcapture material capture effect (Emerald axe)
Jvm-09 byte code introduction
函数栈帧的创建和销毁
C language brush questions ~leetcode and simple questions of niuke.com
WinDbg分析dump文件