`

Java is Pass-by-Value

阅读更多

This often heard saying is not correct: "primitives are passed by value, and objects are passed by reference"

 

in Java everything is passed by value. Primitives are passed by value, and object references are passed by value. The objects themselves are never passed to a method, but the objects are always in the heap and only a reference(value) to the object is passed to the method.

 

http://stackoverflow.com/questions/40480/is-java-pass-by-reference

 

http://javadude.com/articles/passbyvalue.htm

 

just refer to the following two definitions and maybe you'd find the answer.

Pass-by-value
The actual parameter (or argument expression) is fully evaluated and the resulting value is copied into a location being used to hold the formal parameter's value during method/function execution. That location is typically a chunk of memory on the runtime stack for the application (which is how Java handles it), but other languages could choose parameter storage differently.
Pass-by-reference
The formal parameter merely acts as an alias for the actual parameter. Anytime the method/function uses the formal parameter (for reading or writing), it is actually using the actual parameter.
分享到:
评论

相关推荐

    Pass by value VS Pass by Reference

    详细讲解了Java的值传递和引用传递,英文版,易懂,配图片分析!!

    servlet2.4doc

    A filter configuration object used by a servlet container to pass information to a filter during initialization. flushBuffer() - Method in interface javax.servlet.ServletResponse Forces any content ...

    Java邮件开发Fundamentals of the JavaMail API

    The Simple Mail Transfer Protocol (SMTP) is defined by RFC 821 . It defines the mechanism for delivery of e-mail. In the context of the JavaMail API, your JavaMail-based program will communicate ...

    JSP Simple Examples

    Forms are used to pass user- data to a specified URL which is specified in the action attribute of the form tag. Interface in jsp In interface none of its methods are implemented. All the methods ...

    Effective C++ 中文版

    条款20:宁以pass-by-reference-to-const替换Pass-by-value 条款21:必须返回对象时,别妄想返回其reference 条款22: 将成员变量声明为private 条款23: 宁以non-member、non-friend替换member函数 条款24:若...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...

    java的传值与传引用详解

     Java 方法的参数是简单类型的时候,是按值传递的 (pass by value)。这一点我们可以通过一个简单的例子来说明: /* 例 1 */ /** * @(#) Test.java * @author fancy */ public class Test { public static void...

    tomcat-5.5.23

    Directory used by the JVM for temporary files (java.io.tmpdir) <br>If you do not pass the "-Dcatalina.base=$CATALINA_BASE" argument to the startup command, $CATALINA_BASE will default to the ...

    CE中文版-启点CE过NP中文.exe

    ExecuteCodeEx(Let's you execute code in the target and pass parameters) Added 2 new parameters to getNameFromAddress (ModuleNames and Symbols) Added addModule and deleteModule to the symbollist class ...

    测试培训教材

    WR-AUTOMATED A test that is executed by WinRunner, Mercury's functional testing tool for Microsoft Windows applications. LR-SCENARIO A scenario that is executed by LoadRunner, Mercury's load ...

    GifDecoder

    * frames as specified by their disposition codes). */ protected void setPixels() { // expose destination image's pixels as int array int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer...

    python3.6.5参考手册 chm

    Print Is A Function Views And Iterators Instead Of Lists Ordering Comparisons Integers Text Vs. Data Instead Of Unicode Vs. 8-bit Overview Of Syntax Changes New Syntax Changed Syntax Removed ...

Global site tag (gtag.js) - Google Analytics