当前位置:网站首页>Whether the modification of basic type and reference type is valid
Whether the modification of basic type and reference type is valid
2022-06-12 06:23:00 【Fishbone CC】
public class TestTransferValue {
public void changeValue1(int age){// copy 3
age = 30;// What is modified is also a copy
}
public void changeValue2(Person person){
person.setPersonName("xxx");
}
public void changeValue3(String str){
str = "xxx";
}
public static void main(String[] args) {
TestTransferValue test = new TestTransferValue();
int age = 20; // ( For basic types ) original script 1
test.changeValue1(age);// Pass the copy in 2
System.out.println("age----"+age); // At this moment, the output is the original 4
Person person = new Person("abc");
test.changeValue2(person);
System.out.println("personName----"+person.getPersonName());
String str = "abc"; //abc In the constant pool
test.changeValue3(str);
System.out.println("String----"+str);
}
}
result : age----20
personName----xxx
String----abc
Person person( Point to person Type references ) = new Person(“abc”);( example )

Spread changeValue3 When it's inside str Point to abc,r then str="xxx" You need to find... From the constant pool first xxx, Create in constant pool if not found xxx, then str Point to xxx, At this time, the output is still output main Method str, It still points to abc, And new changeValue Inside str Equivalent to not using .
summary : Pass the basic type unchanged , Transfer reference type change
边栏推荐
- Touch screen setting for win7 system dual screen extended display
- Simple spiral ladder generation for Houdini program modeling
- (UE4 4.27) customize primitivecomponent
- 夜神模擬器adb查看log
- BRDF of directx11 advanced tutorial PBR (2)
- sqlite交叉编译动态库
- Houdini terrain creation
- Redis data type (VII) -- hyperloglog
- LeetCode-997. Find the town judge
- RMB classification II
猜你喜欢

Houdini & UE4 programmed generation of mountains and multi vegetation scattering points
![How to increase heap size of JVM [duplicate] - how to increase heap size of JVM [duplicate]](/img/65/a214d137e230b1a1190feb03660f2c.jpg)
How to increase heap size of JVM [duplicate] - how to increase heap size of JVM [duplicate]

Tips for using the potplayer video player

使用 ms17-010 永恒之蓝漏洞对 win7 进行渗透及建立永久后门

MNIST handwritten data recognition by RNN

Directx11 advanced tutorial PBR (1) summary of physical phenomena of light

Introduction to the method of diligently searching for the alliance procedure

Findasync and include LINQ statements - findasync and include LINQ statements

In unity3d, billboard effect can be realized towards another target

LeetCode-419. Battleship on deck
随机推荐
2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
Multithreading (IV) -- no lock (IV) -- unsafe
PDF. JS help file
Houdini script vex learning
n次贝塞尔曲线
Explanation of sensor flicker/banding phenomenon
Multithreading (4) -- no lock (2) -- Atomic related atomic classes
(UE4 4.27) customize primitivecomponent
Automatic modeling of Interchange
leetcode 278. First wrong version
cv2.fillPoly coco annotator segment坐标转化为mask图像
zip 和.items()区别
English语法_副词_有无ly,意义不同
MNIST handwritten data recognition by RNN
SQLite cross compile dynamic library
Video fire detection based on Gaussian mixture model and multi-color
LeetCode-219. Duplicate Element II present
单通道图片的读入
Leetcode sword finger offer (Second Edition) complete version of personal questions
Leetcode personal question solution (Sword finger offer3-5) 3 Duplicate number in array, 4 Find in 2D array, 5 Replace spaces