The Wayback Machine - https://web.archive.org/web/20201013054023/https://github.com/Snailclimb/JavaGuide/issues/876
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4.2. 为什么 Java 中只有值传递? 答非所问 #876

Open
CarterYang0 opened this issue Jul 30, 2020 · 0 comments
Open

1.4.2. 为什么 Java 中只有值传递? 答非所问 #876

CarterYang0 opened this issue Jul 30, 2020 · 0 comments

Comments

@CarterYang0
Copy link

@CarterYang0 CarterYang0 commented Jul 30, 2020

建议修改答案如下
为什么java中只有值传递:
1.选择值传递的原因:为了保护实参,牺牲空间做值拷贝
2.只保留的原因:统一只用值传递,简单方便安全易懂(这个想法和取消指针不谋而和)
注:其他语言保留引用传递的原因:方便修改实参,不用拷贝实参,节约空间时间
(才疏学浅,欢迎斧正)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.