...。除非你指定其他方式,函数参数会用实际参数值的拷贝进行初始化,函数调用者会获得函数返回值的一份拷贝。这些拷贝由对象的拷贝构造函数生成。这使得按值传递(pass-by-value)变成一项昂贵的操作。举个例子,考虑下面的类继承体系(Item 7): 1 class Person {
基于126个网页-相关网页
pass by value 传值 ; 值传递 ; 传递的
Pass-by-reference or Pass-by-value 援用传递照样值传递
Page Pass By Value Technical 页面传值技术
If you need runtime polymorphism, you must not use pass-by-value.
如果你需要运行时多态,你不能使用按值传递。
However, you must be aware that these alternatives change the semantics of the interaction from pass-by-value to pass-by-reference.
然而,您必须注意到这些可供选择的方案会将交互方法从按值传递(pass - by - value)改变为按引用传递(pass - by - reference)。
So what does pass-by-value actually mean? To answer this, it's instructive to look at some JVM1 bytecodes that result from the following two commands.
那值传递到底是什么意思?要回答这个疑问,有须要看一下运行以下两行命令后的JVM的字节码。
应用推荐