使参数为null [英] making an argument null

查看:119
本文介绍了使参数为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有类似的东西:

Let''s say I have something like:

展开 | 选择 | Wrap | 行号

推荐答案

不,当将对象传递给函数时,传递引用。
No, when passing an object to a function, you pass a reference.



不,当将对象传递给函数时,传递一个参考。
No, when passing an object to a function, you pass a reference.



我真诚地讨厌Gosling将这些指针命名为引用。 Java传递了

所有东西,是值得一切的东西,当我们谈论对象时,我们基本上是/ b $ b总是谈论指向对象的指针(我们必须称之为''references'') 。


按值传递意味着副本由要传递的值组成。因此,如果我们认为我们传递了一个对象,我们就会传递一个指向该对象的指针副本。并且

澄清了这一切。


将对象(或其后代)变量想象为

的遥控器实际的电视机。我们可以在一台电视机上安装多个遥控器,并且当我们想将它们作为参数传递给方法时,会复制
遥控器。


亲切的问候,


Jos

I sincerely hate it that Gosling named those pointers ''refererences''. Java passes
everything, yes everything by value and when we talk about objects we basically
always talk about pointers to objects (which we have to call ''references'').

Pass by value means that a copy is made of the value to be passed. So if we
think we pass an object we pass a copy of the pointer to that object. And that
clarifies it all.

Think of an Object (or descendant thereof) variable as a remote control to an
actual TV set. We can have more than one remote control to one TV set and
remote controls are copied when we want to pass them as parameters to methods.

kind regards,

Jos


是的我是这么认为的,但是我仍然需要解决这个问题...

yes I thought so, but I still need a workaround for this problem...

展开 | 选择 | Wrap | 行号


这篇关于使参数为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆