argument passing in java

原创 2006年06月06日 17:21:00

In generally, there are two ways that a computer language can pass an argument to a subroutine. The first way is call-by-value. This method copies the value of an argument into the formal parameter of the subroutine. Therefore, changes made to the parameter of the subroutine have no effect ont the argument. The second way an argument can be passed is call-by-reference. In this method, a reference to an argument (not the value of the argument) is passed to the parameter. Inside the subroutine, this reference is used to access the actual argument specified in the call. This means that changes made to the parameter will affect the argument used to call the subroutine. As you will see, Java uses both approaches, depending upon what is passed.

    In java, when you pass an object to a method, the situation changes dramatically, because objects are passed by reference. Keep in mind that when you create a variable of a class type, you are only creating a reference to an object. Thus, when you pass this reference to a method, the parameter that receives it will refer to the same object as that referred to by the argument. This effectively means that objects are passed to methods by use of call-by-reference. Changes to the object inside the method do affect the object used as an argument.

Remeber:
When a simple type is passed to a method, it is done by use of call-by-value. Objects are passed by use of call-by-reference.

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Name for argument type [java.lang.String] not available, and parameter name information not found in

1、错误描述[ERROR:]2015-11-15 21:13:48,029 [异常拦截] exception.ExceptionHandler java.lang.IllegalArgumentExc...

“passing argument 2 0f “request_irq” from incompatible pointer type”导致中断申请失败和模块无法加载

今天在些key的driver的时候。。。写完了编译出现一个warmming如下: warning: passing argument 2 of 'request_irq' from incompat...

Message Passing Leads to Better Scalability in Parallel Systems

Message Passing Leads to Better Scalability in Parallel SystemsRussel WinderPROGRAMMERS ARE TAUGHT f...

Passing Array From Javascript To PHP in Joomla!1.5

Debug in Javascript How to use 'Alert' : var variablename = 7; function show_alert() ...

Message Passing Leads to Better Scalability in Parallel Systems

Programmers are taught from the very outset of their study of computing that concurrency — and espec...

解决Warning: NEWFF used in an obsolete way. See help for NEWFF to update calls to the new argument li

解决Warning: NEWFF used in an obsolete way.  【转载请注明出处】http://blog.csdn.net/guyuealian/article/details...

opencv Error:Bad argument <Unknown arrray type> in cvarrTomat

2014年7月7日 这几天自己chan

【GMT5】Ubuntu16.04下安装GMT5.2.1报错non-floating-point argument in call to function __builtin_isnan

按照SeisMan提供的教程进行安装:GMT 5.2.1 在 Linux 下的安装检查GMT 的依赖关系完毕后,开始编译和安装,使用make -j后出现如下问题: error: non-floatin...

Passing Domain Credentials in C# to a WebBrowser Control in .Net WinForms Applications(winform中传递域认)

Passing Domain Credentials in C# to a WebBrowser Control in .Net WinForms Applications (winform应用中传递...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)