Java编程语言和Java指南中关于Java的参数传递的解释
来源:互联网 发布:哈尔滨医科大学知乎 编辑:程序博客网 时间:2024/05/16 01:43
From The Java Programming Language, by James Gosling et al. 3rd edition (pg.
56):
quote:
Some people will say incorrectly that objects are passed "by reference."In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked
function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in
memory. The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made
through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
From The Java Tutorial
quote:
Pass by Value
In Java methods, arguments are passed by value. When invoked, the method receives the value of the variable passed in. When the argument is of primitive type, pass -by-value means that the method
cannot change its value. When the argument is of reference type, pass-by-value means that the
method cannot change the object reference, but can invoke the object's methods and modify the accessible variables within the object. This is often the source of confusion--a rogrammer writes a method that attempts to modify the value of one its arguments and the method doesn't work as expected.
Let's look at such method and then investigate how to change it so that it does what the programmer originally intended.
- Java编程语言和Java指南中关于Java的参数传递的解释
- java中关于参数传递问题的解释(传…
- java实现C语言解释器:无参数传递的函数调用的解释和执行
- 关于java中参数传递的问题
- 关于java中参数传递的理解和总结
- 关于java参数的传递
- java中关于参数传递问题的解释(传值与传引用的若干问题的解释)
- 关于JAVA中参数传递问题的总结(按值传递和引用传递)
- java中参数的传递
- java中参数的传递
- java中参数的传递
- Java中参数的传递
- 关于"Java中方法参数的传递方式"的探讨
- 关于"Java中方法参数的传递方式"的探讨
- 深入解析Java编程中方法的参数传递
- 关于JAVA中参数传递问题的总结
- 关于Java中方法调用时参数的传递
- 关于java中参数传递的几点疑惑
- 即时刷新的新闻
- 编译sis文件
- 托管代码中的指针
- (15)'c++:COMPLETE REFERENCE' 第一部分 第二章(表达式) 第七、八节
- 微软推测试版VoIP软件 Office获语音通信能力
- Java编程语言和Java指南中关于Java的参数传递的解释
- logic:iterate标签当遍历的collection为Map时的使用
- PHP 中的cookie的使用
- PV和Alexa都不可靠 网络广告在瞎投
- ORALCE的执行计划稳定性(zt)
- 算法.数学.初级.求最大公约数--辗转相除法,powerbuilder powerscript实现
- XML-RPC规范
- XML的简单读取与写入
- I have a dream